convert formula to vba

  • Thread starter Thread starter tony wong
  • Start date Start date
T

tony wong

i put this formula to vba
=CONCATENATE("Text", C2)


VBA
Cells(2, 1).Formula = "=CONCATENATE("Text", C2)"


how to deal with the double quote with text? thanks a lot.

tony
 
Use the ascii code for a double quote:

Cells(2, 1).Formula = "=CONCATENATE(" & Chr(34) & "Text" & Chr(34) & ", C2)"
 
What moon gave you will work but it seems easier to use:
ActiveSheet.Cells(2,1).Formula = "=CONCATENATE(""Text"",C2)"
 
JLGWhiz said:
What moon gave you will work but it seems easier to use:
ActiveSheet.Cells(2,1).Formula = "=CONCATENATE(""Text"",C2)"

I never understood the need of =CONCATENATE anyway, since strings can easily
be concatenated with the &:

ActiveSheet.Cells(2,1).Value = "Text" & ActiveSheet.Cells(2,3).Value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top