Macro to Hide Row based on Value and then change Checkbox value

C

CSK

I have a macro written that cycles through every worksheet in my workbook
looking for a value of "Hide" in column D. If the criteria is meet, the row
is then hidden. This macro is working nicely. I want to take it a step
further, and in addition to hiding the row, set the form checkbox value to
False. The corresponding checkboxes are in Column B, range is B40:B52. Not
every row that meets the criteria to be hidden has a checkbox that needs to
be changed to false, but if the line does have a checkbox in column B, then I
want it turned to false.

My code looks like this:
Private Sub hiderowsif()
Dim WS As Worksheet

For Each WS In ActiveWorkbook.Worksheets
WS.Select
For Each c In Range("D3:D500")
If c.Value = "Hide" Then
c.Rows.Hidden = True
End If

Next c
Next WS

End Sub
 
J

Joel

the following code will get all the check boxes and the last line shows how
to check (or uncheck if false) the boxes.

Sub getcheckboxes()

For Each Myshape In Worksheets("Sheet2").Shapes

ShapeName = Myshape.Name

Next Myshape

Worksheets("Sheet2").CheckBoxA.Value = True
End Sub
 
C

CSK

I am not sure I was clear as to what I need. My problem is not changing all
the checkboxs to False, but that I only want to change the checkbox in column
B to false if the value on the same row in column D is "Hide". I want to
hide and change the checkbox in the same macro.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top