Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default Macro is not working

I'm getting this error Run Time error '91' Object variable or with block
variable not set.

When I hover the cursor over
shtFixD.CodeName - I get
shtFixD.CodeName = 'shtFixD' - which is correct

When I hover the cursor over
UpdateSht - I get
UpdateSht = nothing - which is the problem


Sub testrange()

Dim UpdateSht As Worksheet
Select Case shtInput.Range("RiskT").Value
Case Is = "Fixed"
UpdateSht = shtFixD.CodeName
Case Else
UpdateSht = shtVarD.CodeName
End Select

UpdateSht.Range("C16").EntireRow.Hidden = True

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Macro is not working

UpdateSht is a worksheet and must be set using the Set keyword.

Not sure why CodeName is in use, can you not use the internal sheet, e.g.:

Dim UpdateSht As Worksheet
Select Case shtInput.Range("RiskT").Value
Case "Fixed"
Set UpdateSht = shtFixD
Case Else
Set UpdateSht = shtVarD
End Select


--
Tim Zych
www.higherdata.com
Compare data in Excel and find differences with Workbook Compare
A free, powerful, flexible Excel utility


"Brad" wrote in message
...
I'm getting this error Run Time error '91' Object variable or with block
variable not set.

When I hover the cursor over
shtFixD.CodeName - I get
shtFixD.CodeName = 'shtFixD' - which is correct

When I hover the cursor over
UpdateSht - I get
UpdateSht = nothing - which is the problem


Sub testrange()

Dim UpdateSht As Worksheet
Select Case shtInput.Range("RiskT").Value
Case Is = "Fixed"
UpdateSht = shtFixD.CodeName
Case Else
UpdateSht = shtVarD.CodeName
End Select

UpdateSht.Range("C16").EntireRow.Hidden = True

End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default Macro is not working

Thank you.

--
Wag more, bark less


"Tim Zych" wrote:

UpdateSht is a worksheet and must be set using the Set keyword.

Not sure why CodeName is in use, can you not use the internal sheet, e.g.:

Dim UpdateSht As Worksheet
Select Case shtInput.Range("RiskT").Value
Case "Fixed"
Set UpdateSht = shtFixD
Case Else
Set UpdateSht = shtVarD
End Select


--
Tim Zych
www.higherdata.com
Compare data in Excel and find differences with Workbook Compare
A free, powerful, flexible Excel utility


"Brad" wrote in message
...
I'm getting this error Run Time error '91' Object variable or with block
variable not set.

When I hover the cursor over
shtFixD.CodeName - I get
shtFixD.CodeName = 'shtFixD' - which is correct

When I hover the cursor over
UpdateSht - I get
UpdateSht = nothing - which is the problem


Sub testrange()

Dim UpdateSht As Worksheet
Select Case shtInput.Range("RiskT").Value
Case Is = "Fixed"
UpdateSht = shtFixD.CodeName
Case Else
UpdateSht = shtVarD.CodeName
End Select

UpdateSht.Range("C16").EntireRow.Hidden = True

End Sub





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro that isn't working Brad Excel Discussion (Misc queries) 2 October 29th 09 08:23 PM
macro not working Jonathan Cooper Excel Discussion (Misc queries) 1 February 1st 06 10:06 PM
macro was working, now it's not working RichardO[_11_] Excel Programming 2 June 9th 04 06:27 AM
Macro working in Excel 2003; not working in Excel 2000 Leslie Barberie Excel Programming 5 May 20th 04 07:51 PM
Macro not working ced[_2_] Excel Programming 1 September 18th 03 10:09 PM


All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"