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.
 

Some videos you may like

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

jasmith4

Active Member
Joined
May 16, 2008
Messages
337
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
 

russ0627

New Member
Joined
Jan 29, 2014
Messages
4

ADVERTISEMENT

Ok...almost there. I need it to copy data from Sheet1 and paste to Sheet2. Thank you for all of your help so far!!
 

jasmith4

Active Member
Joined
May 16, 2008
Messages
337
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,469
Messages
5,596,328
Members
414,054
Latest member
Sameer50

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
Top