Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with single & double quotes 1

Status
Not open for further replies.

robojeff

Technical User
Dec 5, 2008
220
US

I always get confused on the use of single and double quotes...

I am trying to set a string named strRwk to equal "objXLBook.Sheets("Sheet1").Range("E3:E15")"
but I am not sure how to set this up...

I am trying to replace:

.SeriesCollection.Add Source:=objXLBook.Sheets("sheet1").Range("E3:E15")

with:

strRwk= "objXLBook.Sheets("Sheet1").Range("E3:E15")"
.SeriesCollection.Add Source:=strRwk

=======================
That way if I wish to load up a different worksheet of an Excel spreadsheet, I can do the following:

(code...)
sheet = 1
Gosub fpy

(code...)
sheet = 2
Gosub fpy

(code...)
sheet = 3
Gosub fpy

goto end

fpy:
Select Case sheet

Case 1
strRwk= "objXLBook.Sheets("Sheet1").Range("E3:E15")"

Case 2
strRwk= "objXLBook.Sheets("Sheet2").Range("E3:E15")"

Case 3
strRwk= "objXLBook.Sheets("Sheet3").Range("E3:E15")"

End Select

.SeriesCollection.Add Source:=strRwk
(even more code...)

return

end:

Is there a way to set a string up with this value?

 
The easiest way is probably to replace all double quotes with two double quotes:

Code:
strRwk = "objXLBook.Sheets(""Sheet1"").Range(""E3:E15"")"

 
fpy:
.SeriesCollection.Add Source:=objXLBook.Sheets("Sheet" & sheet).Range("E3:E15")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you Remou & PHV... both methods work well but I have chosen PHV's approach as it cuts down on a lot of code

thanks again to both of you for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top