Visual Basic CheckBox Codes

S

Su

Hi

I am currently working on an Excel spreadsheet and I have been using the
following type of coding for a number of CheckBoxes:

Private Sub CheckBox174_Click()
If CheckBox174.Value = True Then
Rows("193").Hidden = False
Rows("318").Hidden = False
Else
Rows("193").Hidden = True
Rows("318").Hidden = True
End If
End Sub

Am I able to name/label the rows so that I do not need to redo the coding
every time I insert or delete a row into the spreadsheet? If so, how would I
need to amend the above code?

Cheers
 
S

ShaneDevenshire

Hi Su,

Yes, here is one way:

Private Sub CheckBox174_Click()
If CheckBox174.Value = True Then
Range("First").EntireRow.Hidden = False
Range("Second").EntireRow.lHidden = False
Else
Range("First").EntireRow.Hidden = True
Range("Second").EntireRow.Hidden = True
End If
End Sub
 

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