0

In Excel VBA I have the following code:

For i = 1 To lRow

Range("A" & i).Formula = "=CONCATENATE(""Print ('"";A" & i & ";""','"";B" & i & ";""','"";C" & i & ";""','"";D" & i & ";""',"";E" & i & ";"","";IF(ISBLANK(F" & i & ");""null"";F" & i & ");"",'"";G" & i & ";""',"";H" & i & ";"",'"";I" & i & ";""','"";J" & i & ";""',"";K" & i & ";"","";L" & i & ";"",'"";M" & i & ";""',"";IF(ISBLANK(N" & i & ");""null"";N" & i & ");"","";O" & i & ";"","";P" & i & ";"","";Q" & i & ";"","";R" & i & ";"",'"";S" & i & ";""',"";T" & i & ";"",'"";U" & i & ";""',"";V" & i & ";"","";W" & i & ";"","";X" & i & ";"","";Y" & i & ";"","";Z" & i & ";"","";AA" & i & ";"","";AB" & i & ";"",'"";AC" & i & ";""',"";AD" & i & ";"",'"";AE" & i & ";""');"")"

Range("A" & i).NumberFormat = "General"

Next i

it works fine and it correctly inserts the formula into the cells.

But, even if I set the format of the cells as "General", Excel diplays the formula as text. So I have to manually click cell by cell on the Sheet to let the formula work. How can I solve it?

My goal is to insert the formula via VBA without having to manually fix the formula clicking cell by cell in the Sheet.

Thanx a lot of you know how to solve

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
David
  • 1
  • 3
    Your cells are presumably formatted as text. They should be formatted as general, and use `.FormulaLocal` instead of `.Formula`. Also, you don't need to loop. `Range("A1:A" & lRow).FormulaLocal = ...`. – BigBen Oct 07 '21 at 20:38
  • 1
    Thanx a lot indeed @BigBen it solved! – David Oct 07 '21 at 21:32

0 Answers0