ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Visual Basic CheckBox Codes (https://www.excelbanter.com/excel-discussion-misc-queries/171892-visual-basic-checkbox-codes.html)

SU

Visual Basic CheckBox Codes
 
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

ShaneDevenshire

Visual Basic CheckBox Codes
 
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


--
Cheers,
Shane Devenshire


"Su" wrote:

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



All times are GMT +1. The time now is 01:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com