I have a workbook (250+named sheets) with an this button on an master sheet. I am attempting to pull the value from B2 if the tab name matches and paste the description into each sheet in C5.
The following code works but is only copying the first field value to the individual sheets instead of looping through finding the name of the sheet and grabbing the value that matches from the master sheet.
Any help is greatly appreciated!!
Example of master
JobName JobDescription
ProgramA Run first
ProgramB Run second
The following code works but is only copying the first field value to the individual sheets instead of looping through finding the name of the sheet and grabbing the value that matches from the master sheet.
Any help is greatly appreciated!!
Example of master
JobName JobDescription
ProgramA Run first
ProgramB Run second
Code:
Works but copying only the first row instead of looping through each
Private Sub CommandButton1_Click()
Custom$ = Left(Range("A2"), 5)
Range("B2").Copy 'currently copying the first value instead of looping through each
Dim WS_Count As Integer
Dim I As Integer
'Set WS_COunt equal to the number of worksheets in teh active workbook
WS_Count = ActiveWorkbook.Worksheets.Count
'Begin loop
For I = 1 To WS_Count
If Left$(ActiveWorkbook.Worksheets(I).Name, 5) = Custom$ Then
Worksheets(I).Activate
End If
' Find the first empty row in the worksheet
'erow = Activate.Cells(Rows.Count, 1).End(x1Up).Offset(1#).Row
ActiveSheet.Paste Destination:=Worksheets(I).Range("C5")
Next I
ActiveWorkbook.Close
End Sub