ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Quotation marks and variables within code (https://www.excelbanter.com/excel-programming/375976-quotation-marks-variables-within-code.html)

Pablo

Quotation marks and variables within code
 
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?


Bob Phillips

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?





All times are GMT +1. The time now is 02:59 AM.

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