VBA - Inserting a formula on next row

LittleJon

New Member
Joined
Oct 14, 2018
Messages
18
I am trying to get some VBA code, that will insert a formula in the next available row in Column I.

The formula needs to match the contents of Column C and O in that row with the cells in the row above and return with the contents of the cell above.

I hope you can see the image i've tried to link.

In this case, the VBA code would insert a formula into Column I row 8, the formula will see the company name in Column C row 8 and the 1st line of the address in Column O row 8, it would then check if the contents of the cells above (Column C & Column O Row 7) are a match and would then put in the same 3rd party reference as Column I row 7.

What would be the best formula for this, nested IF or IF AND?

Any help would be appreciated.

www.imageupload.co.uk/images/2018/10/15/Londonpods.png" border="0"></a>http://www.imageupload.co.uk/images/2018/10/15/Londonpods.png" border="0"></a>
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Welcome to the forum.

You could use something like this:

Code:
Cells(rows.count, "I").end(xlup).offset(1).formular1c1 = "=IF(AND(RC3=R[-1]C3,RC15=R[-1]C15),R[-1]C,"""")"
 
Upvote 0
RC3 means "this row, third column" (i.e. col C of the row with the formula)
R[-1]C3 means "the row above, third column". (i.e. col C of the row above the formula row)
 
Upvote 0

Forum statistics

Threads
1,223,956
Messages
6,175,613
Members
452,661
Latest member
Nonhle

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