insert row code

ryan_law2000

Well-known Member
Joined
Oct 2, 2007
Messages
738
Im looking to have vba code that will:

Insert a row
but continue on the formula in order from the cells above and below

I have formulas in columns
E - F - I

Those are the only columns i want the formula to entered in the new inserted row (but must be the next row in the formula not a exact copy)

I also need another code that will remove the row and fix the formulas to match the row

Hopefully i explained this good enough

Thanks!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
the question are not clear to me

suppose the data is like this (see column G)

Excel Workbook
ABCDEFGH
141620467313513
2436728652176363
3582954771482219
Sheet1


now try this macro on this sample sheet. is this what you want

Code:
Sub test()
Dim j As Integer
For j = Range("A1").End(xlDown).Row To 1 Step -1
If Cells(j, "G") = Cells(j, "E") - Cells(j, "F") - 1 Then
Cells(j + 1, "G").EntireRow.Insert
Cells(j + 1, "G") = Cells(j + 1, "E") - Cells(j + 1, "F") - 1
End If
Next j
End Sub
 
Upvote 0
I have tried this code and all i get is a debug at
"If Cells(j, "G") = Cells(j, "E") - Cells(j, "F") - 1 Then"

Anyone have a way to fix this?
 
Upvote 0
did you try the macro on my sample sheet or in your original sheet. is there any difference in configuration. post a sample of your sheet
 
Upvote 0
I have tried the original code that you posted and it didnt work.
I have never posted a sample of my sheet before, how do i do this?
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,553
Members
452,928
Latest member
101blockchains

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