taNkbilen123
New Member
- Joined
- Feb 14, 2020
- Messages
- 5
- Office Version
- 365
- Platform
- Windows
- MacOS
Hi,
Im new to this site and also creating macros, but this macro feels like it should be easy…
I have a checkbox that hide and unhide rows. If that checkbox is true when i press a specific button i want the rows that are visible to be copied into a new sheet for printing otherwise not. But it doesn't work for me...
The code for the checkbox that hide and unhide rows:
And the code for the button that should copy the rows if the checkbox is true:
If i delete the if-statement in the code for the button it always copy the rows. But i only want it to copy if the checkbox is true.
Can someone help me?
Thank you in advance
Im new to this site and also creating macros, but this macro feels like it should be easy…
I have a checkbox that hide and unhide rows. If that checkbox is true when i press a specific button i want the rows that are visible to be copied into a new sheet for printing otherwise not. But it doesn't work for me...
The code for the checkbox that hide and unhide rows:
Code:
Private Sub cb_as_Click()
If Me.cb_as = True Then
Rows("182:191").Select
Selection.EntireRow.Hidden = False
Range("H177").Select
Else
Rows("182:191").Select
Selection.EntireRow.Hidden = True
Range("H177").Select
End If
End Sub
And the code for the button that should copy the rows if the checkbox is true:
Code:
Sub GenereraRB()
If cb_as = True Then
Sheets("Data").Select
Range("A180:H191").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("sheet 2").Select
Range("A43").Select
ActiveSheet.Paste
End If
End Sub
If i delete the if-statement in the code for the button it always copy the rows. But i only want it to copy if the checkbox is true.
Can someone help me?
Thank you in advance
Last edited by a moderator: