Wildcards in Excel VBA - HELP

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
if you know exactly how many characters are same them you can use
left() function to arrive

hope this helps:

Sub test()

tst = Left(ActiveCell.Text, 19)


Select Case tst

Case "Personal Banking - "
ActiveCell.Interior.ColorIndex = 13 ' Purple'

End Select



End Sub
 
You can't use a wildcard directly in a Select Case; it treats it as a
literal. And it doesn't seem to accept a 'like' clause either - but you can
specify a range and you can do it that way, e.g.
Case "Personal Banking - " To "Personal Banking -Z"
 
Select Case lcase(Left(Somthing,16))
Case "personal banking"

Case "creditor analysi"

End Select
 
Back
Top