Tried the following formula with Absolute referencein VBA but get Application Defined Error

SamDsouza

Board Regular
Joined
Apr 16, 2016
Messages
205
Hello
I put the following formula in cell CE3
IF(BE3<$A$1,BF3,0)+IF(BJ3<$A$1,BK3,0)+IF(BQ3<$A$1,BR3,0)

how to replica in VBA. as i get Appln. Defined Error
Code:
with Ws
.Range("CE3").Formula = "=if(" & "BE3<(R[-2]C[-82]" & "," & "BF3" & "," & "0" & ")"
End with
i could not move further because of error
Regards
Samd
 
Last edited:

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.
Enter the formula into CE3, then turn on the macro recorder, select CE3 & press F2 then Enter.
Turn of the recorder & you have the code
 
Upvote 0
SamD

Try the following:
Code:
With ws
.Range("CE3").Formula = "=IF(" & "BE3<$A$1" & "," & "BF3" & "," & "0" & ")" & "+IF(" & "BJ3<$A$1" & "," & "BK3" & "," & "0" & ")" & _
 "+IF(" & "BO3<$A$1" & "," & "BP3" & "," & "0" & ")" & "+IF(" & "BT3<$A$1" & "," & "BU3" & "," & "0" & ")" & _
 "+IF(" & "BY3<$A$1" & "," & "BZ3" & "," & "0" & ")"
End With
NimishK
 
Upvote 0
Or just
Code:
Range("CE3").Formula = "=IF(BE3<$A$1,BF3,0)+IF(BJ3<$A$1,BK3,0)+IF(BQ3<$A$1,BR3,0)"
 
Upvote 0
NimishK and Fluff Thank you so much for the perfect syntax coding

By the way Macro Recording Steps were slightly difficult to digest. ;)

Thanks Anyways

SamD
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

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