Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Different color on cell [newbie] Jon Excel Discussion (Misc queries) 2 June 26th 09 11:17 AM
cell formatting [newbie] Jon Excel Discussion (Misc queries) 3 March 28th 09 06:41 PM
Real Newbie newbie question Dave New Users to Excel 0 January 10th 07 07:55 PM
Newbie help with cell reference carlab68 Excel Programming 4 December 9th 03 09:58 PM
Newbie : Combo box on cell ? RM[_2_] Excel Programming 2 October 26th 03 06:37 PM


All times are GMT +1. The time now is 02:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"