copying data from one sheet to another

sl1990

New Member
Joined
Jun 3, 2011
Messages
20
Hi,

im to macros and this forum im having trouble with copying data from a sheet called "setup" to the same place in 150 other sheets named "sheet1-150"

so far ive got -

Code:
Sub Bookie_names_first()
    Range("F1:V1").Select
    Selection.Cut
    Range("B1").Select
    ActiveSheet.Paste
    
    Application.CutCopyMode = False
End Sub

the only problem with this is it dose it all in the same sheet i want to copy from "setup" and paste in the 150 others how would i do this ?

thanks in advance
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Code:
Sub Bookie_names_first()
    
    Dim i As Long
    
    For i = 1 To 150
        Sheets("Sheet" & i).Range("B1:R1").Value = Sheets("Setup").Range("F1:V1").Value
    Next i

End Sub
 
Upvote 0
Try something like this that is tested for 3 sheets

Code:
Sub test()
Dim i As Integer
Dim ws As Worksheet


Set ws = Worksheets("Sheet1")

For i = 2 To Worksheets.Count
  ws.Range("f1:j1").Copy Destination:=Worksheets(i).Range("F1:G1")
Next i
Application.CutCopyMode = False


End Sub
Hi,

im to macros and this forum im having trouble with copying data from a sheet called "setup" to the same place in 150 other sheets named "sheet1-150"

so far ive got -

Code:
Sub Bookie_names_first()
    Range("F1:V1").Select
    Selection.Cut
    Range("B1").Select
    ActiveSheet.Paste
    
    Application.CutCopyMode = False
End Sub
the only problem with this is it dose it all in the same sheet i want to copy from "setup" and paste in the 150 others how would i do this ?

thanks in advance
 
Upvote 0
thanks alphafrog!

but when i run this i get an error saying :

run-time error:'9':
subscript out of range

and an option to debug where it highlights the line

"Sheets("Sheet" & i).Range("B1:R1").Value = Sheets("Setup").Range("F1:V1").Value"

any ideas ?

thanks
 
Upvote 0
The code assumes your sheets are named Sheet1, Sheet2, Sheet3...., Sheet149, Sheet150.

And of course you have a sheet named Setup as well

Code:
Sheets([COLOR="Red"]"Sheet" & i[/COLOR]).Range("B1:R1").Value = Sheets("[COLOR="Blue"]Setup[/COLOR]").Range("F1:V1").Value

I would guess you're missing a sheet or the names are different from what the code expects.
 
Upvote 0
SORRY ! did somthing stupid left out sheet26 out of my workbooks Thanks very much GK039 and ALPHAFROG !
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,904
Members
452,948
Latest member
Dupuhini

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