1 min readfrom Microsoft Excel | Help & Support with your Formula, Macro, and VBA problems | A Reddit Community

String variables in .formula - VBA

I need .formula = in that column 19, because I want it to update when values are changed manually after macro was run.

ws.Cells(i,19).Formula = "=JEŻELI(P" & i & "=""test"";K" & i & ";""test2"")"

"Test" and "Test2" are strings that I want to insert into .Formulabut, I think I am missing some "" or something :D

"=JEŻELI" is polish version of "=IF"

Any ideas how string interpolation work in VBA?

Edit: Wait, do I need another "" around the whole expression?

Edit2: No, I guess not...

Edit3: OK solved - Apparently you need to use english function name and "," in .formula, so this works:

"=IF(P" & i & "=""test"",K" & i & ",""test2"")"

submitted by /u/numbian
[link] [comments]

Want to read more?

Check out the full article on the original site

View original article

Tagged with

#AI formula generation techniques
#no-code spreadsheet solutions
#rows.com
#Excel compatibility
#Excel alternatives for data analysis
#.formula
#VBA
#macro
#string interpolation
#ws.Cells
#=JEŻELI
#=IF
#Polish
#Test
#Test2
#expression
#update
#values
#strings
#function name