Using VBA to copy unique values across multiple sheets

Excels Ghost

New Member
Joined
Aug 27, 2019
Messages
4
Hi Experts,

I have a situation where I am looking to copy data from one sheet across a range of cells on multiple other sheets but the copied value is dynamic.

So --
Sheet1 has a list of items that I want copied to other sheets, starting in cell A1.
Sheet2 has a range of B1:Y1 that I need the value A1 from Sheet1 copied to.
Sheet3 has the same range of B1:Y1 that needs copied to but I need it to use A2 from Sheet1.
Sheet4 is the same range but use A3 Sheet1, etc.

I need this process to repeat for all active sheets except Sheet1 should be excluded.

Any help would be very much appreciated! :)
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi & welcome to MrExcel.
How about
Code:
Sub ExcelsGhost()
   Dim i As Long
   For i = 2 To Sheets.Count
      Sheets("Sheet" & i).Range("B1:Y1").Value = Sheets("Sheet1").Range("A" & i - 1)
   Next i
End Sub
 
Upvote 0
Hi and thank you.

I tried that out and got a subscript out of range error on the line below. I'm still pretty new to VBA so sorry for my ignorance on this error, but any thoughts as to what maybe causing it?

Code:
[/FONT]Sheets("Sheet" & i).Range("B1:Y1").Value = Sheets("Sheet1").Range("A" & i - 1)
 
Upvote 0
It means that one of the sheets doesn't exist in the workbook.
Are your sheets actually called (as seen on the sheet tab) Sheet1, Sheet2 etc?
 
Upvote 0
Ok, how about
Code:
Sub ExcelsGhost()
   Dim i As Long
   For i = 2 To Sheets.Count
      Sheets("Sheet1 (" & i & ")").Range("B1:Y1").Value = Sheets("Sheet1").Range("A" & i - 1)
   Next i
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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