Quotation marks and variables within code

P

Pablo

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?
 
B

Bob Phillips

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


--

HTH

Bob Phillips

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

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

Top