VBA If Statements

doublej41

Board Regular
Joined
Mar 9, 2011
Messages
86
Hi All,

I currently use goal seek in cells A1, A2 and A3, with a button to initiate the function in all 3 cells. Currently it calculates them one after the other.

Can someone please help with a VBA if statement to ensure that the goal seek function is only run for non-blank cells, meaning that only the required calculations are carried out? i.e. I only want the goal seek function to run if there is a value in the cells A1, A2 or A3.

At the moment I just have these 3 lines of code, but cannot get an if statement to work correctly:

Code:
Range("CR4").GoalSeek Goal:=0, ChangingCell:=Range("A1")
Range("CR9").GoalSeek Goal:=0, ChangingCell:=Range("A2")
Range("CU4").GoalSeek Goal:=0, ChangingCell:=Range("A3")

Thanks for any and all help.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

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