View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 380
Default Quotation marks and variables within code

Newcodeline = "Sheets(" & """" & NewCompName & """" & ").Visible = True"


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Pablo" wrote in message
oups.com...
I am using the replaceline function to change some code. Part of the
new code is a variable. I want to add the variable value in the new
code, not the variable name.

Newcodeline = "Sheets(" & """ & NewCompName & """ & ").Visible = True"
What I get is ...
Sheets(" & NewCompName & ").Visible = True

I have tried multiple variants but I can't get a right combination. I
can get
Sheets("NewCompName").Visible = True

but not what I want. Ej: if NewCompName were Mckinsey, I want to see

Sheets("Mckinsey").Visible = True

Any suggestions?