Excel VBA equivalent of formula ""

Soldato
Joined
20 Jun 2004
Posts
5,914
Location
Essex
Trying to construct an IF formula that is input to a cell via a macro... whenever I specify "" (as in IF A1="") it throws up an error.

So if I can't use "", what can I use to mean "blank"?
 
edit - nvm reread your post, have I got this right: you want the macro to run and then populate a cell with the formula?

If so then, double quotes should do the trick:

e.g. Range("A1") = "=if(A2>0,"""")"
 
Last edited:
I created a simple macro the other day to add a specified amount to each cell that was not empty, or = "";

Heres a snippet of the Sub, it may or may not be useful.

Dim SelectedRange As Range
For Each SelectedRange In Selection

If (IsEmpty(SelectedRange) Or SelectedRange = "") Then
''do something for empty/blank cells
ElseIf IsNumeric(SelectedRange) Then
''Do calculations
SelectedRange = calculation result
End If
Next
 
Last edited:
Back
Top Bottom