Macro to quickly add if statement to already filled cells

d2theustin

New Member
Joined
Jun 10, 2018
Messages
1
Hello there,

I have a spreadsheet with already filled data/formulas. I want to add an if statement to ensure if the reference cell is blank it shows the cell blank until a value is filled.. like: =IF(ISBLANK(E24),"",F24/G24).. I know how to do that.

However, I don't want to go through every single cell and do this as there are a lot of data points/calculations. so is there a way to create a macro to do this for me.. Here's my sheet:
https://drive.google.com/open?id=1wdg-gLFHuO54uA3DklhSoRrYSSkTWlRE

So basically, I want to add =IF(ISBLANK(E4),"",ALREADY ENTERED FORMULA) to all the cells in Cols I-N. and have the macro understand to change E4 to E5 and so on as it goes down the sheet.

Just trying to save some time to not go through and re-type all the formulas.

Hope this makes sense..

D
 

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
Give this macro a try...
Code:
[table="width: 500"]
[tr]
	[td]Sub AddTestForBlanksToFormulas()
  Dim LastRow As Long, Cell As Range
  LastRow = Columns("I:N").Find("*", , xlFormulas, , xlRows, xlPrevious, , , False).Row
  For Each Cell In Range("I2:N" & LastRow)
    If Cell.HasFormula Then Cell.Formula = "=IF(ISBLANK(E" & Cell.Row & "),""""," & Mid(Cell.Formula, 2) & ")"
  Next
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,216,084
Messages
6,128,722
Members
449,465
Latest member
TAKLAM

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