If cell in column A is zero

singlgl1

Board Regular
Joined
Jan 13, 2007
Messages
127
I'm trying to avoid going to individual formulas to make this change so I hope there's a way to do this for the whole sheet using a code, so here goes:
I have a sheet where I'd like to instruct that if cells in Column B are zero, then all intersecting cells to the right will be zero as well, otherwise use formulas associated with these cells.

For Example,If cell B8=0, then cells C8:AE8 will equal 0.
I'd like to do this for the range B8:AE38
Hope this makes sense.

Thanks!
 
Thanks Rick,
That will save a lot of time indeed.Perhaps that should have been my request from the start since I was trying to avoid going into each individual formula and making these changes.
Thanks again. I'll keep you posted!
Greg
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Rick,
I will need to make one slight change;
Where the code says For Each Cell In Range("C" & StartRow & ":AE" & LastRow)

I will need for this to start at row 8 and end at row 38 instead of startrow & lastrow.
How would I make that change in the code?

Thanks!
 
Upvote 0
Rick,
I will need to make one slight change;
Where the code says For Each Cell In Range("C" & StartRow & ":AE" & LastRow)

I will need for this to start at row 8 and end at row 38 instead of startrow & lastrow.
Well, if the range is guaranteed to be fixed like that, then this should work...
Code:
Sub FixFormulas()
  Dim Cell As Range
  For Each Cell In Range("C8:AE38")
    If Cell.HasFormula Then Cell.Formula = Replace(Cell.Formula, "=", "=IF(B" & Cell.Row & "=0,0,", , 1) & ")"
  Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,156
Messages
6,183,236
Members
453,152
Latest member
ChrisMd

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