Hiding/unhiding different rows

chobanne

Active Member
Joined
Jul 3, 2011
Messages
269
Hi all,

I need a help with this

I need a macro who will according to the values in single cell hide some rows and unhide others in other sheet.

Example:

if in sheet ENTER cell value A1=TRUE hide rows 1,2,3,4 and unhide rows 5,6,7,8 in sheet EXIT, if in sheet ENTER cell value A1=FALSE hide rows 5,6,7,8 and unhide rows 1,2,3,4 in sheet EXIT. In any case 4 rows must always be hidden.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try this: right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "A1" Then
    Select Case Target.Value
        Case True: Sheets("EXIT").Rows("1:4").Hidden = True: Sheets("EXIT").Rows("5:8").Hidden = False
        Case True: Sheets("EXIT").Rows("1:3").Hidden = False: Sheets("EXIT").Rows("5:8").Hidden = True
    End Select
End If
End Sub
 
Upvote 0
VoG
Code:
 Select Case Target.Value
        Case True: ....
        Case True: ....
    End Select
Pardon?
 
Upvote 0
VoG
Code:
 Select Case Target.Value
        Case True: ....
        Case True: ....
    End Select
Pardon?


Oops!

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "A1" Then
    Select Case Target.Value
        Case True: Sheets("EXIT").Rows("1:4").Hidden = True: Sheets("EXIT").Rows("5:8").Hidden = False
        Case False: Sheets("EXIT").Rows("1:3").Hidden = False: Sheets("EXIT").Rows("5:8").Hidden = True
    End Select
End If
End Sub

Thanks :)
 
Upvote 0
Oops!

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "A1" Then
    Select Case Target.Value
        Case True: Sheets("EXIT").Rows("1:4").Hidden = True: Sheets("EXIT").Rows("5:8").Hidden = False
        Case False: Sheets("EXIT").Rows("1:3").Hidden = False: Sheets("EXIT").Rows("5:8").Hidden = True
    End Select
End If
End Sub

Thanks :)

What sheet to select for view code ENTER or EXIT
 
Upvote 0
Code:
Select Case Target.Value
...
        Case False: Sheets("EXIT").Rows("[B][COLOR="Red"]1:3[/COLOR][/B]").Hidden = False...
    End Select
Pardon?
 
Upvote 0
From OP
In any case 4 rows must always be hidden.

I misread that

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "A1" Then
    Select Case Target.Value
        Case True: Sheets("EXIT").Rows("1:4").Hidden = True: Sheets("EXIT").Rows("5:8").Hidden = False
        Case False: Sheets("EXIT").Rows("1:4").Hidden = False: Sheets("EXIT").Rows("5:8").Hidden = True
    End Select
End If
End Sub
 
Last edited:
Upvote 0
From OP

I misread that

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "A1" Then
    Select Case Target.Value
        Case True: Sheets("EXIT").Rows("1:4").Hidden = True: Sheets("EXIT").Rows("5:8").Hidden = False
        Case False: Sheets("EXIT").Rows("1:4").Hidden = False: Sheets("EXIT").Rows("5:8").Hidden = True
    End Select
End If
End Sub

I dont know whats the problem but it wont work m8, nothing happens, What sheet to select for view code ENTER or EXIT
 
Upvote 0
Sorry

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A1" Then
    Select Case Target.Value
        Case True: Sheets("EXIT").Rows("1:4").Hidden = True: Sheets("EXIT").Rows("5:8").Hidden = False
        Case False: Sheets("EXIT").Rows("1:4").Hidden = False: Sheets("EXIT").Rows("5:8").Hidden = True
    End Select
End If
End Sub
 
Upvote 0
Sorry

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A1" Then
    Select Case Target.Value
        Case True: Sheets("EXIT").Rows("1:4").Hidden = True: Sheets("EXIT").Rows("5:8").Hidden = False
        Case False: Sheets("EXIT").Rows("1:4").Hidden = False: Sheets("EXIT").Rows("5:8").Hidden = True
    End Select
End If
End Sub

Than you it work now, i have one more macro i need so i ll put thread now on first page so if u can help it will be very nice. Thank you again very much.
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,158
Members
452,892
Latest member
yadavagiri

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