Here is one approach which uses Marlett check boxes to select the sheets. The check box is ticked when the cell is selected and unticked when the cell is reselected. Column-B is used as the check box cells for as many rows in column-A as are filled with sheet names.
First, a list of all worksheets in the workbook is created in column-A when sheet1 is activated.
Option Explicit
Private Sub Worksheet_Activate()
Dim i As Long
'create a list of sheet names for the selection list
For i = 1 To Sheets.Count
Cells(i, 1) = Sheets(i).Name
Next i
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim lrow As Long, wsName As String
lrow = Cells(Rows.Count, 1).End(xlUp).Row
wsName = Target.Offset(0, -1).Value
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("B1:B" & lrow)) Is Nothing Then
Target.Font.Name = "Marlett"
If Target = vbNullString Then
Target = "a"
Else
Target = vbNullString
End If
'prevent selection of the source sheet
If wsName = Me.Name Then Target = vbNullString
End If
End Sub
This code, below, is run manually and can be assigned to a button when ready to proceed with copying the ranges.
Note: You will need to adjust ranges in the code, but I suggest you insert a new column between A & B if you want to use the code as is. The source range to copy is already adjusted in the code (shifted 1-column to the right)
Option Explicit
Sub Copy_Cells()
Dim wsName As String, c As Range, lrow As Long
lrow = Cells(Rows.Count, 2).End(xlUp).Row
Application.ScreenUpdating = False
If WorksheetFunction.CountIf(Range("B1:B" & lrow), "a") = 0 Then
MsgBox "Sheet selections were not made - cancelling action", vbExclamation
Exit Sub 'no selections made
End If
For Each c In Range("B2:B" & lrow)
If c.Value = "a" Then
wsName = c.Offset(0, -1).Value
If wsName <> "Sheet1" Then
Range("C3:AL3").Copy Worksheets(wsName).Range("A1")
End If
End If
Next c
'Clear the selections after copying the values
With Sheet1
.Range("B1:B" & lrow).ClearContents
End With
Application.ScreenUpdating = True
End Sub
Bookmarks