Macro to insert row above depending on a certain cell value

Tigran

New Member
Joined
Mar 30, 2021
Messages
6
Office Version
  1. 2019
Platform
  1. Windows
Hello,

I am really new to VBA/Macro, and this is my first question here, so please bear with me.

I am trying to write a macro for the following situation, but so far I have not had any luck.
I am using Excel 2019.
Below is a simplified view of my excel sheet that in reality has more than 100k rows like this:

ABCD
25512551true
25522552true
25542555false
25552557false

Column A is one table, columns C and D - another.
Column D contains an IF formula to compare if columns A and C are equal and show true or false.
I am keeping two sets of data in different table to auto-update the formula results after any rows changes.
What I need is a macro to:
1. check column D from up to down (since whatever VBA I have found in forums check from down up),
2. find the false result (while the value is in a formula),
3. insert a row above the row with the false value,
4. after this happens, the table will have the following view:

ABCD
25512551true
25522552true
2554false
25552555true
2557false

5. the row with 2555 values will become "true", and I want the macro to go down (not start looking from 1st row anew), find the next "false", insert row and same way down to the last row of the sheet.

Is such a Macro/VBA possible?
Thanks a bunch in advance, this will save me tons of time.
 

Zot

Well-known Member
Joined
Nov 26, 2020
Messages
1,170
Office Version
  1. 2016
Platform
  1. Windows
OMG, sorry, I was doing something wrong the first time, this works perfectly.
I'd like to make a donation, as you really helped me a lot. I don't know if there is PM feature in this forum, but please let me know your PayPal ID somehow.
Thanks again!

T.
No need for donation. The forum is to provide help, not to make earning.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Watch MrExcel Video

Forum statistics

Threads
1,129,791
Messages
5,638,340
Members
417,021
Latest member
moon miner

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
Top