Hi Everyone,
I am new to VBA and Excel. I am trying to do something like this with a macro:
In a sheet there are 4 headers (cells with colored title). Under each header, there are multiple checkboxes.
I want to copy only the checked Checkboxes and paste them into a new sheet under the same header.
Eg.
I want to copy checkboxes under Documents and place them under Documents header in the new sheet.
Here is the code which I have tried till now:
My problem is it is copying on the first checked header everytime. Please help.
I am new to VBA and Excel. I am trying to do something like this with a macro:
In a sheet there are 4 headers (cells with colored title). Under each header, there are multiple checkboxes.
I want to copy only the checked Checkboxes and paste them into a new sheet under the same header.
Eg.
I want to copy checkboxes under Documents and place them under Documents header in the new sheet.
Here is the code which I have tried till now:
Code:
Sub chkbxcpy()
Dim actSheet As String
Dim actSheetName As String
actSheetName = ActiveSheet.Name
Dim ChkBx As CheckBox
Dim temp As CheckBox
'Sheets("Installation - Building Info.").Select
Sheets("Request for quote").Select
newSheet = "cpy " & Left(actSheetName, 20)
ActiveWorkbook.Sheets.Add.Name = newSheet
Sheets(actSheetName).Select 'To change the ActiveSheet back to original
For Each ChkBx In ActiveSheet.CheckBoxes
If ChkBx.Value = 1 Then
ChkBx = ChkBx.Accelerator
ChkBx.Select
'MsgBox "ChkBx--" & ChkBx.Caption
Selection.Copy
Sheets(newSheet).Select
ActiveSheet.Paste
End If
Next ChkBx
End Sub
My problem is it is copying on the first checked header everytime. Please help.