defining a variable containing quotation marks

S

Sian

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
 
J

John Bundy

Add quotes around the quotes:
"""OptionButton1""", """OptionButton2"""
or just add them when you output later if possible.
 
S

Sian

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

Dave Peterson

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.
 

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