Hiding command buttons

FrEaK_aCcIdEnT

Board Regular
Joined
May 1, 2012
Messages
100
I am wanting to hide a command button if a condition is met. The below is giving me a type mismatch runtime error.

Code:
If Worksheets("Final").Range("H6:H97").Value = "" Then

WorkSheets("General").Shapes.Range(Array("Button 2")).Hidden
WorkSheets("General").Shapes.Range(Array("Button 3")).Hidden
End If

What am I doing wrong? :confused:
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Update:

I have fiddled with it more and it has to do with the range.

Here is where I am at...

Code:
If Worksheets("Final").Range[COLOR=#ff0000][B]("H97")[/B][/COLOR].Value = "" Then

Worksheets("General").Shapes.Range(Array("Button 2")).Visible = False
Worksheets("General").Shapes.Range(Array("Button 3")).Visible = False

Else

Worksheets("General").Shapes.Range(Array("Button 2")).Visible = True
Worksheets("General").Shapes.Range(Array("Button 3")).Visible = True

End If

I need range H6:H97 to all have something in them to allow the buttons to be visible.
 
Upvote 0
I have switched it around so it works as intended on one cell, but I still need all cells in the range of H6:H97 to contain something instead of being blank for the buttons to show on another sheet.

Thanks for any and all help. Pardon my train of thought that you had to read through to get to this point...

Code:
If Worksheets("Final").Range("[B][COLOR=#ff0000]H97[/COLOR][/B]").Value <> "" Then

Worksheets("General").Shapes.Range(Array("Button 2")).Visible = True
Worksheets("General").Shapes.Range(Array("Button 3")).Visible = True

Else

Worksheets("General").Shapes.Range(Array("Button 2")).Visible = False
Worksheets("General").Shapes.Range(Array("Button 3")).Visible = False

End If
 
Upvote 0
Would H6:H97 actually be empty or do they contain formulas that return "" for example?
 
Upvote 0
They have a data validation dropdown that has Heavy, Medium, Light, N/A. I want all of the cells in that range to have something selected before the buttons appear on the other sheet.

They are also set as "ignore blank" on the data validation and the template is saved with the cells being blank to start off.

No formulas that return a "" value.

Thanks! :)
 
Last edited:
Upvote 0
In that case, try this:
Code:
Worksheets("General").Shapes.Range(Array("Button 2", "Button 3")).Visible = (Application.CountBlank(Worksheets("Final").Range("H6:H97")) = 0)
 
Upvote 0

Forum statistics

Threads
1,215,518
Messages
6,125,291
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top