Hiding sheets based on a value in a cell

JessicaKinnear

New Member
Joined
Jan 6, 2021
Messages
25
Office Version
  1. 365
Platform
  1. Windows
Hey, I'm looking for some help on a VBA code.

I basically have a sheet named 'INPUTS-BULDING DETAILS' then I have 12 sheets named 'Tenant - 1', 'Tenant - 2' etc. all the way up to 12 which I want to hide if a certain cell doesn't contain a value.

On my inputs tab I want to be able to code so that if cell F36 has no value then hide sheet 'Tenant -1', if cell F37 has no value then hide sheet 'Tenant - 2', then this to repeat all the way up to cell F47 and sheet 'tenant - 12'

Does anyone know the correct code for this (I am a complete beginner when it comes to coding so think code for dummies :))

Thank you in advance!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Do you have the sheet names on the INPUTS-BULDING DETAILS, if so what column are they in?
 
Upvote 0
Ok, how about
VBA Code:
Sub Jessica()
   Dim i As Long
   
   For i = 1 To 12
      Sheets("Tenant - " & i).Visible = Sheets("INPUTS-BULDING DETAILS").Range("F" & i + 35) <> ""
   Next i
End Sub
 
Upvote 0
Solution
Ok, how about
VBA Code:
Sub Jessica()
   Dim i As Long
  
   For i = 1 To 12
      Sheets("Tenant - " & i).Visible = Sheets("INPUTS-BULDING DETAILS").Range("F" & i + 35) <> ""
   Next i
End Sub
This doesn't seem to be working, all the sheets are still showing when there is no value
 
Upvote 0
no errors showing, am i putting in the correct place on the inputs building details tab i right click and add it in 'view code'?
 
Upvote 0
Hi, according to your explanation a VBA demonstration to paste to the input worksheet module :​
VBA Code:
Sub Demo1()
    Dim V, R%
        V = [IF({1},TRIM(F36:F47)>"")]
    For R = 1 To 12:  Sheets("Tenant - " & R).Visible = V(R, 1):  Next
End Sub
 
Upvote 0
Shouldn't matter where the code is.
What is in F36:F47? is it had values or a formula?
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,536
Members
449,037
Latest member
tmmotairi

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