Copying 8 rows of data in a new sheet

russ0627

New Member
Joined
Jan 29, 2014
Messages
4
Hello everyone,
I have enjoyed reading all the numerous helpful tips and hints that everyone has given. I have an issue, probably a simple one for the geniuses on here. I am trying to do a macro in Excel 2010 that will take a range from A1:E8 on Sheet1, have a message box ask how many times to copy, and then copy and paste that range however many times I tell it to, including the formulas, onto sheet2. Can someone offer me some assistance? Thank you in advance.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Code:
Sub CopyA1E8()

    Dim NumTimes&, Source As Range 
    NumTimes& = InputBox("How many times", Default:="1")  ' Non-number => error
    
    Set Source = Me.Range("A1:E8")
    With Source.Resize(Source.Rows.Count * (NumTimes& + 1), Source.Columns.Count)
        
        Source.AutoFill .Cells, xlFillCopy
    
    End With

End Sub
 
Upvote 0
Ok...almost there. I need it to copy data from Sheet1 and paste to Sheet2. Thank you for all of your help so far!!
 
Upvote 0
Code:
Sub CopyA1E8()    Dim NumTimes&, Source As Range, Target As Range
    NumTimes& = InputBox("How many times", Default:="1")  ' Non-number => error
    
    Set Source = Sheet1.Range("A1:E8")
    Set Target = Sheet2.Range(Source.Address)
    Source.Copy Target

    With Target.Resize(Target.Rows.Count * (NumTimes& + 1), Target.Columns.Count)
        
        Target.AutoFill .Cells, xlFillCopy
    
    End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,213,535
Messages
6,114,192
Members
448,554
Latest member
Gleisner2

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