Copy & Past Large Amounts of Data

bloodmilksky

Board Regular
Joined
Feb 3, 2016
Messages
202
Hi Guys, I was wondering if anyone can help.

I am trying to use the below to compile an order of different products. ideally what should happen is that it copies Range B7:D69 to sheet 1 and then you can add another group of products to the next empty row. but what is happening at the moment is that everytime you run it, it is just copying over the previous order. can anyone help please ?

Code:
Sub OrderCopy()


Dim lRow As Long
Dim sRangeName As String


    'Copy Cells B7 & D68 On Menu
    Sheets("Menu").Range("B7:D68").Copy
    'To A Range Defined in B5
    sRangeName = Sheets("MENU").Range("B5").Value


    'The range is on menu sheet and is the range defined on sheet1 "a1:d880"
    'get next empty row in named range
    lRow = 1
    Do Until Sheets("Sheet1").Range(sRangeName).Cells(lRow, 1) = ""
        lRow = lRow + 1
    Loop
    'Paste Data
    Sheets("Sheet1").Range(sRangeName).Cells(lRow, 1).PasteSpecial xlPasteAll


End Sub

any help would be greatly appreciated

Jamie
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Jamie,

You might consider the following...

Code:
Sub OrderCopy()

Dim lRow As Long
Dim sRangeName As String

'Copy Cells B7 & D68 On Menu
Sheets("Menu").Range("B7:D68").Copy
'To A Range Defined in B5
sRangeName = Sheets("MENU").Range("B5").Value

lRow = Sheets("Sheet1").Range(sRangeName).Rows.Count + 1
'Paste Data
Sheets("Sheet1").Range(sRangeName).Cells(lRow, 1).PasteSpecial xlPasteAll

End Sub

Cheers,

tonyyy
 
Upvote 0
The only reason I see to use a named range of A1:D880 for sheet1 would be to find the next empty row in that range.

Most people just use sheet1 column A's next empty cell. Does that work for you or MUST you have the next empty row in columns A:D?

Of course it may be that there are no empty rows when you limit it like that.
 
Upvote 0
Code:
Sub OrderCopy()
  'Copy/Paste Cells B7 & D68 On Menu to next empty row on sheet1
  Sheets("Menu").Range("B7:D68").Copy _
      Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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