Insert macro between ranges

DStayman

New Member
Joined
Apr 21, 2011
Messages
11
i have a macro that copies a set of cell from one sheet to another sheet. This information is added when the click a button. The snag is that i need the data to be serted between the already added data and the total formulas at the very bottom. This is the macro i have so far.
Sub
Sheets("Data").Select
Range("A17:O24").Select
Selection.Copy
Sheets("ALLL").Select
Range("A17").Select
Selection.Insert Shift:=xlDown
End Sub
the range A17 is where it gets insert the first time around, but after that it isert it right in the middle of other information. I knoow thats where part of the problem is. Any suggestions?
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Perhaps

Code:
Sheets("Data").Range("A17:O24").Copy
Sheets("ALLL").Range("A" & Rows.Count).End(xlUp).Resize(8).EntireRow.Insert
 
Upvote 0
That almost worked. Now its inserting it inbetween evertything but not at the top anymore. I Bisacally i need it to insert before the totals at the bottom. However the totals locaation in row may not be the same becuase of insertions. I have a macro adding datting to the top each time, i just need this one to add to the bottom, but not very bottom of everything.
 
Upvote 0
as of right now when the data sheet is new to a user and before the start inputting data the totals are added up in h22:m:23. the chart area ends on row 20 but when the start adding new data it will be lowered. Ive already created a macro button that when they click a button it addinfo to the rows pushing everything down. This button i need the information from the the data sheet to be added at the bottom of the already given inforation, but not before the totals? thanks for your help!
 
Upvote 0
How many rows out (and in which direction) is the code that I posted above?
 
Upvote 0
2 rows deep 7 columns in is the totals, other than that im not sure what you mean, thanks for your help by the way
 
Upvote 0
If the totals are the bottom 2 rows of data try

Code:
Sheets("Data").Range("A17:O24").Copy
Sheets("ALLL").Range("A" & Rows.Count).End(xlUp).Offset(-1).Resize(8).EntireRow.Insert
 
Upvote 0
I get a runtime error 1004 - insert method of range failed. My ranges change due to some corrections from a15toq20, maybe tht could be my error.
 
Upvote 0
Let me explain what my code does in words.

First it copies the data (straightforward).

It then looks at the sheet ALL. It finds the last entry in column A, goes up one row and inserts 8 rows (pushing your 2 totals rows down).

Does that sound reasonable?

Incidentally, it worked when I tested it.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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