ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   convert formula to vba (https://www.excelbanter.com/excel-programming/373060-convert-formula-vba.html)

tony wong

convert formula to vba
 
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



moon[_6_]

convert formula to vba
 

Use the ascii code for a double quote:

Cells(2, 1).Formula = "=CONCATENATE(" & Chr(34) & "Text" & Chr(34) & ", C2)"



"tony wong" schreef in bericht
...
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




JLGWhiz

convert formula to vba
 
What moon gave you will work but it seems easier to use:
ActiveSheet.Cells(2,1).Formula = "=CONCATENATE(""Text"",C2)"

"tony wong" wrote:

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




Tom Ogilvy

convert formula to vba
 
Cells(2, 1).Formula = "=CONCATENATE(""Text"", C2)"

--
Regards,
Tom Ogilvy

"tony wong" wrote in message
...
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




moon[_6_]

convert formula to vba
 

"JLGWhiz" schreef in bericht
...
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



tony wong

convert formula to vba
 
Thanks a lot.

they work to me.


"Tom Ogilvy" .gbl...
Cells(2, 1).Formula = "=CONCATENATE(""Text"", C2)"

--
Regards,
Tom Ogilvy

"tony wong" wrote in message
...
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







All times are GMT +1. The time now is 06:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com