Can somebody help me in this problem. I want to hide and unhide some rows in Excell depending from the values entered in cell A1.
If the value in A1=1, unhide rows from 90-130, and hide rows from 131-170
If the value in A1=2, hide rows from 90-130 and unhide rows from 131-170
In any other cases A1, hide rows from 90-170.
Dale Watson the master of Excell programming wrote me this program:
Private Sub Worksheet_Change(ByVal num As Range)
'1 = unhide rng_1 and hide rng_2
'2 = hide rng_1 and unhide rng_2
'anything else, hide rng_1 and rng_2
If ActiveCell.Address <> Range("num"
.Address Then Exit Sub
cursht = ActiveSheet.Name
Sheets(cursht).Unprotect "123"
curcell = ActiveCell.Address
Application.ScreenUpdating = False
If num = 1 Then
Range("rng_1"
.Select
Selection.EntireRow.Hidden = False
Range("rng_2"
.Select
Selection.EntireRow.Hidden = True
ElseIf num = 2 Then
Range("rng_1"
.Select
Selection.EntireRow.Hidden = True
Range("rng_2"
.Select
Selection.EntireRow.Hidden = False
ElseIf num > 2 Then
Range("rng_1"
.Select
Selection.EntireRow.Hidden = True
Range("rng_2"
.Select
Selection.EntireRow.Hidden = True
ElseIf num < 1 Then
Range("rng_1"
.Select
Selection.EntireRow.Hidden = True
Range("rng_2"
.Select
Selection.EntireRow.Hidden = True
End If
Application.Goto Range(curcell), True
Sheets(cursht).Protect "123"
Application.ScreenUpdating = True
End Sub
Dale says it' working on his computer, but on mine just does not work. If I delete any number in cell A1, rows 90-170 are hidden, but other options are not working. Entering A1=1, it does not hide rows 131-170, and rows 90-130 are not unhidden.
Can somebody try out on his computer the check does this program work for given condition? I believe to Dale that it's working on his computer, but why does not work in mine? Did I set something wrong in my Excell?
Does anybody have any idea how can I solve this hide-unhide condition? It looks so easy task, but I just can't solve it.
If the value in A1=1, unhide rows from 90-130, and hide rows from 131-170
If the value in A1=2, hide rows from 90-130 and unhide rows from 131-170
In any other cases A1, hide rows from 90-170.
Dale Watson the master of Excell programming wrote me this program:
Private Sub Worksheet_Change(ByVal num As Range)
'1 = unhide rng_1 and hide rng_2
'2 = hide rng_1 and unhide rng_2
'anything else, hide rng_1 and rng_2
If ActiveCell.Address <> Range("num"
cursht = ActiveSheet.Name
Sheets(cursht).Unprotect "123"
curcell = ActiveCell.Address
Application.ScreenUpdating = False
If num = 1 Then
Range("rng_1"
Selection.EntireRow.Hidden = False
Range("rng_2"
Selection.EntireRow.Hidden = True
ElseIf num = 2 Then
Range("rng_1"
Selection.EntireRow.Hidden = True
Range("rng_2"
Selection.EntireRow.Hidden = False
ElseIf num > 2 Then
Range("rng_1"
Selection.EntireRow.Hidden = True
Range("rng_2"
Selection.EntireRow.Hidden = True
ElseIf num < 1 Then
Range("rng_1"
Selection.EntireRow.Hidden = True
Range("rng_2"
Selection.EntireRow.Hidden = True
End If
Application.Goto Range(curcell), True
Sheets(cursht).Protect "123"
Application.ScreenUpdating = True
End Sub
Dale says it' working on his computer, but on mine just does not work. If I delete any number in cell A1, rows 90-170 are hidden, but other options are not working. Entering A1=1, it does not hide rows 131-170, and rows 90-130 are not unhidden.
Can somebody try out on his computer the check does this program work for given condition? I believe to Dale that it's working on his computer, but why does not work in mine? Did I set something wrong in my Excell?
Does anybody have any idea how can I solve this hide-unhide condition? It looks so easy task, but I just can't solve it.