Copy value from Master based to all sheets on tab name

Mel2016

New Member
Joined
Jun 5, 2016
Messages
41
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




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
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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