ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   defining a variable containing quotation marks (https://www.excelbanter.com/excel-programming/404973-defining-variable-containing-quotation-marks.html)

Sian

defining a variable containing quotation marks
 
I'm trying to do the following:

ActiveSheet.Shapes.Range(Array((myarray)).Select

when myarray is "OptionButton1", "OptionButton2"

I cannot for the life of me work out how to define myarray so that it
contains quotation marks. Can anyone help?
Sian

Gary''s Student

defining a variable containing quotation marks
 
Three double quotes in a row:

Sub jfsldf()
MsgBox ("""hello""")
End Sub
--
Gary''s Student - gsnu200766


"Sian" wrote:

I'm trying to do the following:

ActiveSheet.Shapes.Range(Array((myarray)).Select

when myarray is "OptionButton1", "OptionButton2"

I cannot for the life of me work out how to define myarray so that it
contains quotation marks. Can anyone help?
Sian


John Bundy

defining a variable containing quotation marks
 
Add quotes around the quotes:
"""OptionButton1""", """OptionButton2"""
or just add them when you output later if possible.

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Sian" wrote:

I'm trying to do the following:

ActiveSheet.Shapes.Range(Array((myarray)).Select

when myarray is "OptionButton1", "OptionButton2"

I cannot for the life of me work out how to define myarray so that it
contains quotation marks. Can anyone help?
Sian


Sian

defining a variable containing quotation marks
 
This isn't working for me: I've tried

myarray = """OptionButton1""", """Optionbutton2"""
ActiveSheet.Shapes.Range(Array(myarray)).Select

and I get a compile error

Even if I try
myarray = """OptionButton1"""
ActiveSheet.Shapes.Range(Array(myarray)).Select

I get "Name not found" and myarray in the debugger shows as
""OptionButton10""

I'm trying to do this to delete a variable range of ActiveX objects.
Perhaps there's an easier way to do this?

Dave Peterson

defining a variable containing quotation marks
 
You sure it's the quotation marks?

Array(myArray)
looks kind of funny to me.

Sub testme()
'Dim myArray is undeclared on purpose!

ReDim myArray(1 To 2)
myArray(1) = "OptionButton1"
myArray(2) = "OptionButton2"
ActiveSheet.Shapes.Range(myArray).Select

End Sub

myArray has to be a real array--not just a text string.


Sian wrote:

I'm trying to do the following:

ActiveSheet.Shapes.Range(Array((myarray)).Select

when myarray is "OptionButton1", "OptionButton2"

I cannot for the life of me work out how to define myarray so that it
contains quotation marks. Can anyone help?
Sian


--

Dave Peterson

Sian

defining a variable containing quotation marks
 

Dave, you're right on the money, as ever. Thank you!


All times are GMT +1. The time now is 06:58 AM.

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