I am trying to find out how to copy three rows from one sheet to another based on clicking a checkbox. I am using code from here:
Private Sub CheckBox1_Click()
Dim SrcRange As Range, TrgRange As Range
Set SrcRange = Worksheets("Data Sheet").[B1]
Set TrgRange = Worksheets("Sheet1").[C1]
If CheckBox1 Then
TrgRange = SrcRange
Else
TrgRange = ""
End If
End Sub
This is the code I am currently using for this process:
Private Sub CheckBox1_Click()
Dim SrcRange As Range, TrgRange As Range
Set SrcRange = Worksheets("Data Sheet").Range("A1:E1")
Set TrgRange = Worksheets("Sheet1").Range("A1:E1")
Set SrcRange = Worksheets("Data Sheet").Range("A2:E2")
Set TrgRange = Worksheets("Sheet1").Range("A2:E2")
Set SrcRange = Worksheets("Data Sheet").Range("A3:E3")
Set TrgRange = Worksheets("Sheet1").Range("A3:E3")
If CheckBox1 Then
TrgRange = SrcRange
Else
TrgRange = ""
End If
End Sub
When using this code no error is provided, however none of the data is copied and pasted into the selected worksheet.
Aucun commentaire:
Enregistrer un commentaire