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 |
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 |
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 |
All times are GMT +1. The time now is 02:30 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com