Hi all,
I'm fairly new to VB so detail will be appreciated.
I'm creating a checklist with a checkbox in every row with a written task to check and a macro to hide that task when the box is checked. I am using control forms checkboxes. The thing is i wrote a macro to hide the rows but i did it the lame way by asigning in a select case function each checkbox's name to the row nº underneath it. And there are quite a bunch of tasks so the select case is pretty big.
Then i found out about cell linking to a checkbox and my question is: is there a function or command to retrieve the row nº from the cell's address linked to the checkbox i just clicked ?
If there is no command or fuction able to do such a thing do u know a way for me to get around the burden of having to rewrite my macro every time i introduce a new task/line into the checklist ?
Here is my code :
Sub HideUnhide()
Dim RowNum As Integer
Dim s As String, cbx As CheckBox
s = Application.Caller
Set cbx = ActiveSheet.CheckBoxes(s)
Select Case s
Case "Casilla de verificación 13"
RowNum = 13
Case "Casilla de verificación 12"
RowNum = 17
Case "Casilla de verificación 14"
RowNum = 19
Case "Casilla de verificación 15"
RowNum = 21
Case "Casilla de verificación 16"
RowNum = 23
Case "Casilla de verificación 37"
RowNum = 25
Case "Casilla de verificación 22"
RowNum = 27
Case "Casilla de verificación 19"
RowNum = 31
Case "Casilla de verificación 25"
RowNum = 33
Case "Casilla de verificación 28"
RowNum = 35
Case "Casilla de verificación 40"
RowNum = 37
Case "Casilla de verificación 31"
RowNum = 39
Case "Casilla de verificación 34"
RowNum = 41
Case "Casilla de verificación 43"
RowNum = 45
Case "Casilla de verificación 46"
RowNum = 47
Case "Casilla de verificación 49"
RowNum = 49
Case "Casilla de verificación 52"
RowNum = 51
Case "Casilla de verificación 55"
RowNum = 53
End Select
If cbx.Value = xlOn Then
Worksheets("Hoja1").Rows(RowNum).Hidden = True
Else
Worksheets("Hoja1").Rows(RowNum).Hidden = False
End If
End Sub
Mind the "Casilla de verificación" its spanish for "Checkbox".
Thanks in advance.
Bookmarks