Carole has attended:
Excel VBA Intro Intermediate course
Excel vba
Hi,
I want to show/hide 4 rows & a command button (assigned to a print macro) dependant on a Yes/No response. i have the following code:
If Range("E63") = "Yes" Then
Rows("37:40").EntireRow.Hidden = False
ActiveSheet.Button_16.Visible = True
Else
Rows("37:40").EntireRow.Hidden = True
ActiveSheet.Button_16.Visible = False
End If
When I run it, I get "Runtime Error '438': Object doesn't support this property or method"
If I debug, it highlights the "ActiveSheet" row
Thanx
RE: Excel vba
Hi Carole,
Thank you for your question.
The problem with code is accessing the command button using the Activesheet command.
What I suggest is you select the sheet you are working with as the first line of code(be explicit with the sheet you are working with).
Once the sheet has been explicitly selected then you can use the command cmdButton.visible = true.
Please find the code below and replace the sheet name and button name:
Sheets("Test Sheet").select
If Range("E63") = "Yes" Then
Rows("37:40").EntireRow.Hidden = False
cmdTest.Visible = True
Else
Rows("37:40").EntireRow.Hidden = True
cmdTest.Visible = False
End If
I hope this answers your question.
Regards
Simon
Will be marked as resolved in 5 days
Notice: This is an automated message. Due to inactivity, this forum post will be marked as 'resolved' if there are no further responses in the next 5 days.