Checkbox to hide or unhode rows on a different sheet based on cell value

sdoppke

Well-known Member
Joined
Jun 10, 2010
Messages
647
Hello everyone, I am looking to place a checkbox on sheet1 that will check rows 1-2000 on sheet2 for the value in A1 of sheet1 and hide or unhide those rows based on if its checked or not.

thanks a ton in advacne for any direction.

sd
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hello everyone, I am looking to place a checkbox on sheet1 that will check rows 1-2000 on sheet2 for the value in A1 of sheet1 and hide or unhide those rows based on if its checked or not.

thanks a ton in advacne for any direction.

sd


I have managed to put this together, but its doesnt work :(

Anyone have any ideas?

sd

Code:
Private Sub CheckBox1_Click()
    Dim i As Integer
    First = Sheets("MyStoreInfo").Range("B10")
    Last = Sheets("MyStoreInfo").Range("C10")
    Application.ScreenUpdating = False
    Sheets("Schedule Tool").Visible = True
    Sheets("Schedule Tool").Select
    If Sheets("MyStoreInfo").CheckBox1.Value = True Then
    For i = 4 To 1200
        If Sheets("Schedule Tool").Range("A" & i).Value = First & " " & Last And _
        Sheets("Schedule Tool").Range("A" & i).HasFormula Then
            Rows(i & ":" & i).EntireRow.Hidden = True
        End If
    Next i
    Else
    For i = 4 To 1200
        If Sheets("Schedule Tool").Range("A" & i).Value = First & " " & Last And _
        Sheets("Schedule Tool").Range("A" & i).HasFormula Then
            Rows(i & ":" & i).EntireRow.Hidden = False
        End If
    Next i
    End If
    Sheets("Schedule Tool").Visible = False
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
A couple of questions:

  • Why are you hiding rows on a hidden sheet?
  • How do you know it's not working if the sheet is hidden?
  • You could use AutoFilter to Hide\Unhide rows. Would that work for you?
  • What's the formula in column A?
  • What sheet is the CheckBox on? Can't tell from the code.
  • What version of Excel do you have?
 
Upvote 0
A couple of questions:

  • Why are you hiding rows on a hidden sheet?
  • How do you know it's not working if the sheet is hidden?
  • You could use AutoFilter to Hide\Unhide rows. Would that work for you?
  • What's the formula in column A?
  • What sheet is the CheckBox on? Can't tell from the code.
  • What version of Excel do you have?

Thanks for the reply AlphFrog

  • The sheet is not hidden the code makes the sheet visible
  • (not hidden)
  • Im going to look at the AutoFilter option (never thought of that :) )
  • =MyStoreInfo!$B23&" "&MyStoreInfo!$C23
  • Sheet("MyStoreInfo")
  • 2007
Hope that helps

sd
 
Upvote 0
Perhaps you'll get ideas from this...

Code:
Private Sub CheckBox1_Click()
    
    Dim FirstNLast As String
    
    FirstNLast = Range("B10") & " " & Range("C10")
    
    With Sheets("Schedule Tool")
        If Sheets("MyStoreInfo").CheckBox1.Value = True Then
            .Range("A1:A1200").AutoFilter
            .Range("A1:A1200").AutoFilter Field:=1, Criteria1:=FirstNLast
            .Visible = True
            .Select
        Else
            .AutoFilterMode = False
            .Visible = False
        End If
    End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,916
Members
452,949
Latest member
beartooth91

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