Pasting a range into a sheet

Zain

New Member
Joined
Sep 4, 2007
Messages
43
I'm writing a macro that will create a large number of worksheets. I have one master worksheet with some data on it and I want to copy a range from the master to each of the new sheets. I'm thinking the following:

Dim myRange As Range

myRange = Sheets("Master").Range("A5:A100")

For k = 1 to 100
Set myWS = Worksheets.Add
myWSName = Sheets("Pivot").Cells(4, Col).Value
myWS.Name = myWSName
myWS.Range("A5:A100") = myRange
Next k

Wil this work? Is there a faster way to do it? Thanks.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I think your code needs to be this (changes in bold):
Rich (BB code):
Dim myRange As Range
 
Set myRange = Sheets("Master").Range("A5:A100")
 
For k = 1 to 100
Set myWS = Worksheets.Add
myWSName = Sheets("Pivot").Cells(4, k).Value
myWS.Name = myWSName
myWS.Range("A5:A100") = myRange
Next k
though if you are just copying values across, I would use:

Rich (BB code):
Dim varData
varData = Sheets("Master").Range("A5:A100").Value
application.screenupdating = false
For k = 1 to 100
Set myWS = Worksheets.Add
myWSName = Sheets("Pivot").Cells(4, k).Value
myWS.Name = myWSName
myWS.Range("A5:A100").Value = varData
Next k
application.screenupdating = true
 
Upvote 0
Please describe exactly what you want. In English, with data examples if possible?

Is this a pivottable by any chance? Have you considered the Show Pages pivot command?
 
Upvote 0

Forum statistics

Threads
1,214,891
Messages
6,122,105
Members
449,066
Latest member
Andyg666

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