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

excel vba

ResolvedVersion 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:

Change the Default Width of All Columns in Excel 2010

If you want to change the width of the columns in your Excel 2010 spreadsheet, making them either larger or smaller, here's how:

In the Cells group on the Home tab, click Format.

Hover over the section called Cell Size and a drop down list will appear, select Default Width from this list.

In the Standard Width dialog box, enter the size you want to set as the default width and click OK.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.11 secs.