Checkbox copy

san1646

New Member
Joined
May 17, 2013
Messages
2
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.

5

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. :)
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top