VBA Wildcards - HELP!

C

Co-op Bank

Hello, i'm working in Excel 2000 and I have some VBA code (taken from
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=390) which gives
a segment in a Pie Chart a colour baed on its description. Unfortunatley the
suffix of the segment is always different so I would like to use a wildcard
for the suffix. A typical segment description is "Personal Banking - £100k".
I have tried to insert a wildcard into the code but it does not work (i.e.
change the segment colour), any suggestions?

'Case "Personal Banking - *"
.Points(iPoint).Interior.ColorIndex = 13 ' Purple'

If I type in 'Case "Personal Banking - £100k"
.Points(iPoint).Interior.ColorIndex = 13 ' Purple' it
works fine but with the suffix changing as the data changes its not practical
to manually adjust the code.
Please help.

Thanks
Brian
Manchester, England
 
D

Debra Dalgleish

You can use the Left function, e.g.:

Select Case Left(WorksheetFunction.Index(.XValues, iPoint), 16)
Case "Personal Banking"
.Points(iPoint).Interior.ColorIndex = 6 ' Yellow

Instead of 16, use any number of characters that will uniquely identify
the categories.
 

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