Confused Whitch
New Member
- Joined
- Feb 4, 2015
- Messages
- 1
Sorry I am relatively new to making Macros, I have a basic macro that hides a row when a checkbox is selected. However I don't want to copy and paste the same macro for every line I have the checkbox in.
My (very basic code) is:
ub CheckBox()
If Range("M4").Value = True Then
Call Macro1
Else: Range("M4").Value = False
Call Macro2
End If
End Sub
Sub Macro1()
'
' Macro1 Macro
' Hides a Row
'
' Keyboard Shortcut: Ctrl+h
'
ActiveCell.EntireRow.Hidden = True
End Sub
Sub Macro2()
'
' Macro2 Macro
' Unhides a Row
'
' Keyboard Shortcut:
'
ActiveCell.EntireRow.Hidden = False
End Sub
I need M4 to change to M5 and so on as insert lines etc.... Can anyone point out the obvious mistake to me please.
My (very basic code) is:
ub CheckBox()
If Range("M4").Value = True Then
Call Macro1
Else: Range("M4").Value = False
Call Macro2
End If
End Sub
Sub Macro1()
'
' Macro1 Macro
' Hides a Row
'
' Keyboard Shortcut: Ctrl+h
'
ActiveCell.EntireRow.Hidden = True
End Sub
Sub Macro2()
'
' Macro2 Macro
' Unhides a Row
'
' Keyboard Shortcut:
'
ActiveCell.EntireRow.Hidden = False
End Sub
I need M4 to change to M5 and so on as insert lines etc.... Can anyone point out the obvious mistake to me please.