Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Newbie VBA: How to test second position in a cell?
I'd examine the value using Mid, then check to see if the Ascii code for
the extracted string lay in the correct range: Dim str As String str = Sheet1.Cells(1, 1).Value If (str < "") Then If (Asc(Mid(str, 2, 1)) 47 And Asc(Mid(str, 2, 1)) < 58) Then Sheet1.Cells(1, 2).Value = True Else Sheet1.Cells(1, 2).Value = False End If End If There are probably vastly better ways of doing this though... --- Message posted from http://www.ExcelForum.com/ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Newbie VBA: How to test second position in a cell?
You may have noticed I got it the wrong way round.
Anyway, here it is again but correct, a bit neater & with more validation: Dim str As String str = Sheet1.Cells(1, 1).Value If (str < "") And (Len(str) 1) Then Sheet1.Cells(1, 2).Value = Not (Asc(Mid(str, 2, 1)) 47 And Asc(Mid(str, 2, 1)) < 58) End If --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Different color on cell [newbie] | Excel Discussion (Misc queries) | |||
cell formatting [newbie] | Excel Discussion (Misc queries) | |||
Real Newbie newbie question | New Users to Excel | |||
Newbie help with cell reference | Excel Programming | |||
Newbie : Combo box on cell ? | Excel Programming |