ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   I need to put text in quotes(") (https://www.excelbanter.com/excel-programming/323694-i-need-put-text-quotes.html)

Donna[_7_]

I need to put text in quotes(")
 
Thanks for all inputs so far and sorry this is a seperate thread.
I am nearly there.....
I have:-
CellSel = Range("E1")
i = ActiveSheet.Shapes.Count
Line1 = "Sub CommandButton" & i & "_Click"
With ActiveWorkbook.VBProject.VBComponents(ActiveSheet. CodeName).CodeModule
X = .CountOfLines
.InsertLines X + 1, Line1
.InsertLines X + 2, "d=" & CellSel
.InsertLines X + 3, "End Sub"
End With

where cell E1 contains text Hello and i=1 in this case.
This give me the commandbutton code of:-
Sub CommandButton1_Click()
d=Hello
End Sub

But I need the Hello in quotes ("Hello")....d= "Hello". How can I do this.
Cheers Folkes.

Tom Ogilvy

I need to put text in quotes(")
 
CellSel = char(34) & Range("E1").Text & char(34)

--
Regards,
Tom Ogilvy


"Donna" wrote in message
om...
Thanks for all inputs so far and sorry this is a seperate thread.
I am nearly there.....
I have:-
CellSel = Range("E1")
i = ActiveSheet.Shapes.Count
Line1 = "Sub CommandButton" & i & "_Click"
With

ActiveWorkbook.VBProject.VBComponents(ActiveSheet. CodeName).CodeModule
X = .CountOfLines
.InsertLines X + 1, Line1
.InsertLines X + 2, "d=" & CellSel
.InsertLines X + 3, "End Sub"
End With

where cell E1 contains text Hello and i=1 in this case.
This give me the commandbutton code of:-
Sub CommandButton1_Click()
d=Hello
End Sub

But I need the Hello in quotes ("Hello")....d= "Hello". How can I do

this.
Cheers Folkes.




Dave Peterson[_5_]

I need to put text in quotes(")
 
I bet Tom meant:

CellSel = chr(34) & Range("E1").Text & chr(34)

(chr() instead of char())

Tom Ogilvy wrote:

CellSel = char(34) & Range("E1").Text & char(34)

--
Regards,
Tom Ogilvy

"Donna" wrote in message
om...
Thanks for all inputs so far and sorry this is a seperate thread.
I am nearly there.....
I have:-
CellSel = Range("E1")
i = ActiveSheet.Shapes.Count
Line1 = "Sub CommandButton" & i & "_Click"
With

ActiveWorkbook.VBProject.VBComponents(ActiveSheet. CodeName).CodeModule
X = .CountOfLines
.InsertLines X + 1, Line1
.InsertLines X + 2, "d=" & CellSel
.InsertLines X + 3, "End Sub"
End With

where cell E1 contains text Hello and i=1 in this case.
This give me the commandbutton code of:-
Sub CommandButton1_Click()
d=Hello
End Sub

But I need the Hello in quotes ("Hello")....d= "Hello". How can I do

this.
Cheers Folkes.


--

Dave Peterson

Tom Ogilvy

I need to put text in quotes(")
 
Details, details -- Thanks for the correction!

--
Regards,
Tom Ogilvy

"Dave Peterson" wrote in message
...
I bet Tom meant:

CellSel = chr(34) & Range("E1").Text & chr(34)

(chr() instead of char())

Tom Ogilvy wrote:

CellSel = char(34) & Range("E1").Text & char(34)

--
Regards,
Tom Ogilvy

"Donna" wrote in message
om...
Thanks for all inputs so far and sorry this is a seperate thread.
I am nearly there.....
I have:-
CellSel = Range("E1")
i = ActiveSheet.Shapes.Count
Line1 = "Sub CommandButton" & i & "_Click"
With

ActiveWorkbook.VBProject.VBComponents(ActiveSheet. CodeName).CodeModule
X = .CountOfLines
.InsertLines X + 1, Line1
.InsertLines X + 2, "d=" & CellSel
.InsertLines X + 3, "End Sub"
End With

where cell E1 contains text Hello and i=1 in this case.
This give me the commandbutton code of:-
Sub CommandButton1_Click()
d=Hello
End Sub

But I need the Hello in quotes ("Hello")....d= "Hello". How can I do

this.
Cheers Folkes.


--

Dave Peterson





All times are GMT +1. The time now is 09:51 AM.

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