Multiple times paste

max1995

New Member
Joined
Mar 24, 2020
Messages
13
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi All,

I Will try to attach the file in question.

It's pretty much the same as the first request,all in the same workbook.
I Frequently create new sheets within the same workbook , the first sheet (master) is the blank template
I Copy this template , create a new sheet within the same workbook and paste this template multiple times (ranges from 20-30) times and some times even more

The idea here is that I Want to automate this process so once I Create the new sheet and enter the number of times in a specific cell I Want the template to be Pasted, It's pasted on that new sheet.

P.S I’m a newbie to VBA

any advice would be much appreciated.

Here's the link to the excel file : Template.xlsx

BR,
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
So basically you want multiple copies of the same worksheet. The number depends on the value of a specific cell on a specific worksheet. Am I right?
What's the name of the sheet to be copied and upon which sheet is the cell with the amount of copies?
 
Upvote 0
How about
VBA Code:
Sub max1995()
   Dim i As Long
   
   With Sheets("Master")
      For i = 1 To .Range("D1").Value
         .Copy , Sheets(Sheets.Count)
      Next i
   End With
End Sub
change D1 to the cell that contains the number of copies
 
Upvote 0
So basically you want multiple copies of the same worksheet. The number depends on the value of a specific cell on a specific worksheet. Am I right?
What's the name of the sheet to be copied and upon which sheet is the cell with the amount of copies?
It’s not the entire sheet that I want to copy , just a range of cells in that sheet!

If you got the xls file I uploaded you’ll find the first sheet master with the range already highlighted
I want to paste that range for example 20 time in sheet 2
 
Upvote 0
What range should be copied & where should it be copied to?
Also what cell will hold the number of copies required?
 
Upvote 0
Range is from B1 To H31
destination would be to a new sheet that I create within the same workbook
And the cell that holds the number of copies is cell A7
 
Upvote 0
How about
VBA Code:
Sub max1995()
   With Sheets("Master")
      .Range("B1:H31").Copy ActiveSheet.Range("B1").Resize(31 * .Range("A7").Value)
   End With
End Sub
The new sheet must be the active sheet when you run this
 
Upvote 0
How about
VBA Code:
Sub max1995()
   With Sheets("Master")
      .Range("B1:H31").Copy ActiveSheet.Range("B1").Resize(31 * .Range("A7").Value)
   End With
End Sub
The new sheet must be the active sheet when you run this

I tried the code provided and it returns subscript out of range
 

Attachments

  • New Bitmap Image.png
    New Bitmap Image.png
    7 KB · Views: 10
Upvote 0
In that case check that the master sheet doesn't have any leading/trailing spaces in its name.
 
Upvote 0
In that case check that the master sheet doesn't have any leading/trailing spaces in its name.

I Did , there was one cheeky space ahead of the sheet name
and guess what , It worked like magic
thanks a lot buddy I Really appreciate it
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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