excel vba

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Excel vba

Excel vba

resolvedResolved · Medium Priority · Version 2007

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.

Sun 25 Sep 2011: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Shared Conditional Formatting

In a shared workbook, conditional formats applied before the workbook was shared will continue to work; however you cannot modify the existing conditional formats or apply new ones.

View all Excel hints and tips


Server loaded in 0.08 secs.