Forum Discussion
FatManFluff
Nov 09, 2024Brass Contributor
VBA to add IF Statement
Good morning all, Having a hard time getting VBA to set a formula into a cell when I use the reset button to delete all contents. Currently I am using: Sub AddFormula() Range("P4").Value = "IF(...
- Nov 09, 2024
Try this:
Sub AddFormula() Range("P4").Formula= "=IF(D4<>"""",D4,"""")" End Sub
HansVogelaar
Nov 09, 2024MVP
Try this:
Sub AddFormula()
Range("P4").Formula= "=IF(D4<>"""",D4,"""")"
End Sub
- FatManFluffNov 09, 2024Brass Contributor
Any clue why when I add more than just that 1 range it throws off the formula? EX when I do a second range P5 the formula that gets added is
=@ID(D5<>"",D5,"")
The sheet I'm using has 2 sides an income and outcome and I reference
C to O
D to P
E to Q
I want to do the same formula for P4:Q33 if there is an easier way instead of adding 1 line per cell that would be very helpful.
- FatManFluffNov 09, 2024Brass Contributor
Perfect this worked!! I was so close yet so far! Appreciate the quick reply have a good weekend