PDA

View Full Version : [SOLVED] Problem inserting formula with VBA



chemavecino
06-19-2018, 06:10 AM
Good morning,

I'm having some issues finishing a VBA code (I'm no expert).
The debugger jumps on this line:

Cells(n_fila_nueva, 19).Formula = "=IF(" & Cells(n_fila_nueva, 14).Address & "<1;'00" & Cells(n_fila_nueva, 3) & "'!$M$13;0)"

The weird thing is that if I run the macro without the equals, like:

Cells(n_fila_nueva, 19).Formula = "IF(" & Cells(n_fila_nueva, 14).Address & "<1;'00" & Cells(n_fila_nueva, 3) & "'!$M$13;0)"

And then I add equals to the cell where I'm putting the formula, evetything works fine.


I'm probably making a silly mistake, so if any of the experienced users can give me hand would be much appreciated.

Thanks in advance.

Aflatoon
06-19-2018, 08:09 AM
You need to use commas not semicolons when using the Formula property:


Cells(n_fila_nueva, 19).Formula = "=IF(" & Cells(n_fila_nueva, 14).Address & "<1,'00" & Cells(n_fila_nueva, 3) & "'!$M$13,0)"

chemavecino
06-19-2018, 11:10 PM
Works fine now, thank you so much.
Didn't expect it to be so silly.