|
-
Aug 25th, 2003, 01:25 PM
#1
Thread Starter
Junior Member
VBA for Excel
I have a problem.
I'm trying to run a query that will find all of the cells that look like
A@@@-@@@-@@@-@@@-4@@@. An example of the alphanumeric data in my spreadsheet is A001-457-883-540-4556.
All of the cells begin with an 'A'. However, I only want to identify those with a '4' beginning in the last four digits of A001-457-883-540-4556. Here is a sample of my VBA code:
Sub checkValue()
Dim CurCell As Object
Dim Expression As Object
Dim Format As Variant
Format = VBA.Format("A@@@-@@@-@@@-@@@-4@@@")
'Expression = VBA.Format("A@@@-@@@-@@@-@@@-4@@@")
For Each CurCell In Selection
If CurCell.Value = (VBA.Format("A@@@-@@@-@@@-@@@-4@@@")) Then CurCell.Interior.ColorIndex = 6
Next
End Sub
It works if I specifically say A001-457-883-540-4556. But I don't want just one value. I want all values that begin with the number 4 in the last four digits. I hope that someone can help me. Or that I am not asking too much.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|