VBA wildcards

R

rhatcher

Im trying to use a wildcard calling the names of subshapes (grouped
shapes). The shape names are in the format of "Property Cell.#" or
"Property Cell.TEXT" Like "Property Cell.3" and "Property
Cell.UnitNumber" etc. I want it to iterate through all shapes with
"Property Cell" in the name. However, I cannot get the wild cards that
are in the VBA help to work.

Im trying "*" and "?" although from what Im reading, "*" should work.

My code looks like this:

For Each subShpObj In shpsObj
If subShpObj.Name = "Property Cell.*" Then
UserForm1.ListBox1.AddItem subShpObj.Name
End If
Next

Which finds nothing

If I modify the code to:

If subShpObj.Name = "Property Cell.3" Then

It does find the shape "Property Cell.3" so I know that otherwise the
code works.

What am I doing wrong, are wildcards usable in this case?

thanks
 
R

rhatcher

I found it, to use wildcards requires the LIKE operator.

the new code reads:
If subShpObj.Name Like "Property Cell.*" Then

LIKE that was hard to find :)
 

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