Macro to insert row

mewalker0

New Member
Joined
Jan 24, 2005
Messages
22
Need to find a macro that will check the value "DATE" of a cell and insert a row if the cell below it is greater.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Sub macro()
If ActiveCell.Value < ActiveCell.Offset(1, 0).Value Then ActiveCell.Offset(1, 0).EntireRow.Insert
End Sub

You will need to add in some sort of loop to keep it running, eg:
Sub macro()
counter = 1
do until counter = 500
If ActiveCell.Value < ActiveCell.Offset(1, 0).Value Then ActiveCell.Offset(1, 0).EntireRow.Insert
if activecell.offset(1,0).text = "" then activecell.offset(1,0).select
activecell.offset(1,0).select
counter = counter + 1
loop
End Sub
 
Upvote 0
Welcome to the Board!

How about this:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> InsertRow()
    <SPAN style="color:#00007F">If</SPAN> ActiveCell.Offset(1, 0).Value > ActiveCell.Value <SPAN style="color:#00007F">Then</SPAN> ActiveCell.Offset(1, 0).EntireRow.Insert
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Hope that helps,

Smitty
 
Upvote 0
That works great but what would I have to change to make it look at a range in a collumn instead of starting on the active cell? Looking for a way to add this , run the macro and have if just look within a range.
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,843
Members
449,051
Latest member
excelquestion515

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