macro out ofmemory

CookieMonster76

Board Regular
Joined
Apr 30, 2015
Messages
200
Hi

I have the following which repeats itself over and over, until the point whereby excel cannot run it.

The only difference in each section is the reference to the cells highlighted in red.

Is there a way to consolidate it into a few lines?

Thanks

Paul

With Sheets("Gross Pay")
.Range("A1:B" & .Range("A" & .Rows.Count).End(xlUp).Row).Copy Destination:=Sheets("Costing Report").Range("K1")
.Range("E1:E" & .Range("A" & .Rows.Count).End(xlUp).Row).Copy Destination:=Sheets("Costing Report").Range("N1")
End With
Range("M4:M" & Range("K" & Rows.Count).End(xlUp).Row).Value2 = Range("N3").Value2
Range("K4:N" & Range("K" & Rows.Count).End(xlUp).Row).Copy Destination:=Range("A1048576").End(xlUp).Offset(1, 0)
Range("K:N").Delete

With Sheets("Gross Pay")
.Range("A1:B" & .Range("A" & .Rows.Count).End(xlUp).Row).Copy Destination:=Sheets("Costing Report").Range("K1")
.Range("F1:F" & .Range("A" & .Rows.Count).End(xlUp).Row).Copy Destination:=Sheets("Costing Report").Range("N1")
End With
Range("M4:M" & Range("K" & Rows.Count).End(xlUp).Row).Value2 = Range("N3").Value2
Range("K4:N" & Range("K" & Rows.Count).End(xlUp).Row).Copy Destination:=Range("A1048576").End(xlUp).Offset(1, 0)
Range("K:N").Delete
 
Last edited:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Paul

How are you running the code?

Is it meant to repeat over and over?
 
Upvote 0
Hi

Yes, it is converting a table with (say) 50 columns into a column.

From the table cols A to C are fixed, and repeat in the column. I then want to to col E from the table, then coll F etc.

In essence:


Jones 100 400
Smith 200 500
Brown 300 600

Needs to become


Jones 100
Smith 200
Brown 300
Jones 400
Smith 500
Brown 600
 
Last edited:
Upvote 0
macro out ofmemory
Hi

I have the following which repeats itself over and over, until the point whereby excel cannot run it.


CookieMonster76,

In a copy of your workbook, try adding the below bold lines of code, after each copy command.


Rich (BB code):
With Sheets("Gross Pay")

  .Range("A1:B" & .Range("A" & .Rows.Count).End(xlUp).Row).Copy Destination:=Sheets("Costing Report").Range("K1")

  Application.CutCopyMode = False

  .Range("E1:E" & .Range("A" & .Rows.Count).End(xlUp).Row).Copy Destination:=Sheets("Costing Report").Range("N1")

  Application.CutCopyMode = False

End With
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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