LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default test if a character in a string is alpha

Talk about spoilt for choice! Thanks Alan, it does work a treat.

Happily tripping off to the next stumbling block now.....

Thanks Guys,

Matilda

"Alan" wrote:

Is this what you want?

Sub TestString()

Dim sShift As String
Dim TstStr As String

sShift = <<Populate this variable from somewhere

TstStr = Left(sShift, 2)

If IsNumeric(Left(TstStr, 1)) Then
If Not IsNumeric(Right(TstStr, 1)) Then
TstStr = Left(TstStr, 1)
End If
Else
' Disregard the data
TstStr = ""
End If

End Sub


Matilda wrote:
Hi Bob,

Thankyou... and I should have said I am in VBA not spreadsheet formulas! I
have no chance of working out what your statement is doing, it looks as
though it is errortrapping, testing the type, and putting on the tea!!! I
feel so far away from mastering this stuff ... so glad of your help.

Can you convert it to a VBA statement, please? My variable is sShift and is
a string. I want to get first two characters (which are usually numbers for
workdays) to help me order the list. Where the second character is alpha,
I want only the first, and where the first is an alpha, I want to disregard.

Many thanks,

Matilda

Matilday

"Bob Phillips" wrote:

should have said that it is an array formula, it should be committed with
Ctrl-Shift-Enter, not just Enter.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Matilda" wrote in message
...
Dear All,

I need to convert part of a string to a number. the string can be x
characters long, but I only want the first teo characters, where they are
numbers.

I am having trouble catching cases where wither first or second character
is
alpha.

If (Mid(sshift, 2, 1) = "A") Or (Mid(sshift, 2, 1) = "P") Then
iShftStart = CInt(Left(sshift, 1)) ' case where shift is written as 8AM
or
8PM
Else
iShftStart = CInt(Left(sshift, 2))
End If

my conditions need to include any ascii alpha character, really.

Any suggestions?


Many thanks,

Matilda





 
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
if alpha character samuel Excel Discussion (Misc queries) 4 December 17th 08 03:22 AM
How to test if the end character of a string is within a user-definedlist? T2net Excel Discussion (Misc queries) 8 February 26th 08 01:43 PM
Excel-Match 1st text character in a string to a known character? bushlite Excel Worksheet Functions 2 January 15th 07 06:36 PM
Function to return Character Position of Xth character within a string Andibevan[_2_] Excel Programming 4 June 9th 05 03:24 PM
Increment Alpha Character Dan Excel Programming 4 June 3rd 04 07:32 PM


All times are GMT +1. The time now is 03:23 PM.

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

About Us

"It's about Microsoft Excel"