Sheet visible on cell valeu

aBcdcg

New Member
Joined
Oct 24, 2018
Messages
12
Hello,

Below a part of a code.
I wan't to change a part of this. Sheets X was always vidible, but it may only be visible if the valeu on 'Sheet11 cell A1 = > 5'

I have test it whit the IIf function, but i make some little mistake...

Code:
Sub Generate ()  t = Sheets("Sheet 1").Cells(3, 1).Value
  If t > 0 Then
    Application.DisplayAlerts = False

    [B]Sheets("X" & t).Visible = True[/B]
    ....
    ....


Thanks !
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Perhaps Sheet11 is a typing error?
Amend if necessaey

Code:
With Sheets("X")
    .Visible = False
    If Sheets("Sheet[COLOR=#ff0000]11[/COLOR]").Range("A1") >= 5 Then .Visible = True
End With

both conditions together like this
Code:
    With Sheets("X")
        .Visible = False
        If Sheets("Sheet 1").Cells(3, 1) > 0 And Sheets("Sheet[COLOR=#ff0000]11[/COLOR]").Range("A1") >= 5 Then .Visible = True
    End With
 
Last edited:
Upvote 0
Hello,

It's a part of a code, the bold text in the code will repeat a few times for other sheets. They will not be changed.

- 'Sheet11' is not a typo.
- The first 3 line of the code can not be change, that menas that a new code not can be made;
- only the bold text in the code can be canged.
- The conditions in the first 3 line has to stay there.
 
Upvote 0
Try the first code I gave you in post#2
But maybe replace
Code:
With Sheets("X")
[in your explanation]

With...
Code:
With Sheets("X" & t )
[in your code]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,927
Messages
6,122,311
Members
449,080
Latest member
jmsotelo

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