Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default How to test variable for chr values

Hi,

I'm trying to parse a part number for quoting.

The part numbers could be, for example:

21718R22C1210055
21718R100440055
E1801B10031B0403
A1801A10069N0055
A3216S63100N1421

In the following code snippet,
I want to return into a string variable, EntrySize,
for a 217 type part, a certain part of a string Mid(r.Text, 10, 2),
if Mid(r.text,9,1)= chr(67), or chr(65) or
chr(68) or chr(45) or chr(82).

If not, I want EntrySize to equal Mid(r.text,9,2)

Below, I was trying to make a sAlph hold that variable, but I don't
know how to write it.

I'm grateful for any assistance.

Thanks,

Dan
----------------------------------------------------------------------------------------

ElseIf Left(r.Text, 1) = "E" Or Left(r.Text, 1) = "A" Then_
'If it's other than E or A, this won't work.
FuncDesignator = Left(r.Text, 1)
ConnectorCode = Mid(r.Text, 2, 2)
SeriesPartNo = Mid(r.Text, 4, 2)
Style = Mid(r.Text, 6, 1)
RayFormula = FuncDesignator & "XX" &_
SeriesPartNo & Style
OrderNum = Mid(r.Text, 7, 2)
EntrySize = Mid(r.Text, 9, 2)
Clamp = Mid(r.Text, 11, 1)
With Worksheets("A&E")
Set myDestRng = .Range("D2")
.Range("D2") = RayFormula
Set myDestRng = .Range("E2")
.Range("E2") = ConnectorCode
Set myDestRng = .Range("F2")
.Range("F2") = OrderNum
Set myDestRng = .Range("H2")
.Range("H2") = EntrySize
Set myDestRng = .Range("I2")
.Range("I2") = Clamp
End With
End

Else
BAN = Left(r.Text, 3)
'Debug.Print "BAN: "; BAN, "Connector Code:_
", ConnectorCode
ConnectorCode = Mid(r.Text, 4, 2)
sAlph = Mid(r.Text, 9, 1)

Style = Mid(r.Text, 6, 1)
RayFormula = BAN & "XX" & Style
OrderNum = Mid(r.Text, 7, 2)

?EntrySize = If sAlph=true, then
EntrySize = Mid(r.Text, 9, 2)

Clamp = Mid(r.Text, 11, 1)
With Worksheets("217")
Set myDestRng = .Range("E2")
.Range("E2") = RayFormula
Set myDestRng = .Range("G2")
.Range("G2") = ConnectorCode
Set myDestRng = .Range("K2")
.Range("K2") = OrderNum
Set myDestRng = .Range("H2")
.Range("H2") = EntrySize
Set myDestRng = .Range("I2")
.Range("I2") = Clamp
End With
End
End If
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 915
Default How to test variable for chr values

dan dungan wrote:

Hi Dan, not sure if I totally get the question, but see within. Also,
why so many chr() instead of plain text? chr(67) chr(65) chr(68) chr(45)
chr(82) is just strings C A D - R

Hi,

I'm trying to parse a part number for quoting.

The part numbers could be, for example:

21718R22C1210055
21718R100440055
E1801B10031B0403
A1801A10069N0055
A3216S63100N1421

In the following code snippet,
I want to return into a string variable, EntrySize,
for a 217 type part, a certain part of a string Mid(r.Text, 10, 2),
if Mid(r.text,9,1)= chr(67), or chr(65) or
chr(68) or chr(45) or chr(82).

If not, I want EntrySize to equal Mid(r.text,9,2)

Below, I was trying to make a sAlph hold that variable, but I don't
know how to write it.

I'm grateful for any assistance.

Thanks,

Dan
----------------------------------------------------------------------------------------

ElseIf Left(r.Text, 1) = "E" Or Left(r.Text, 1) = "A" Then_
'If it's other than E or A, this won't work.
FuncDesignator = Left(r.Text, 1)
ConnectorCode = Mid(r.Text, 2, 2)
SeriesPartNo = Mid(r.Text, 4, 2)
Style = Mid(r.Text, 6, 1)
RayFormula = FuncDesignator & "XX" &_
SeriesPartNo & Style
OrderNum = Mid(r.Text, 7, 2)
EntrySize = Mid(r.Text, 9, 2)
Clamp = Mid(r.Text, 11, 1)
With Worksheets("A&E")
Set myDestRng = .Range("D2")
.Range("D2") = RayFormula
Set myDestRng = .Range("E2")
.Range("E2") = ConnectorCode
Set myDestRng = .Range("F2")
.Range("F2") = OrderNum
Set myDestRng = .Range("H2")
.Range("H2") = EntrySize
Set myDestRng = .Range("I2")
.Range("I2") = Clamp
End With
End

Else
BAN = Left(r.Text, 3)
'Debug.Print "BAN: "; BAN, "Connector Code:_
", ConnectorCode
ConnectorCode = Mid(r.Text, 4, 2)
sAlph = Mid(r.Text, 9, 1)

Style = Mid(r.Text, 6, 1)
RayFormula = BAN & "XX" & Style
OrderNum = Mid(r.Text, 7, 2)

?EntrySize = If sAlph=true, then


' one way
If InStr(1, Chr(67) & Chr(65) & Chr(68) & Chr(45) & Chr(82), sAlph) Then

'easier to read
If InStr(1, "CAD-R", sAlph) Then

EntrySize = Mid(r.Text, 9, 2)

Clamp = Mid(r.Text, 11, 1)
With Worksheets("217")
Set myDestRng = .Range("E2")
.Range("E2") = RayFormula
Set myDestRng = .Range("G2")
.Range("G2") = ConnectorCode
Set myDestRng = .Range("K2")
.Range("K2") = OrderNum
Set myDestRng = .Range("H2")
.Range("H2") = EntrySize
Set myDestRng = .Range("I2")
.Range("I2") = Clamp
End With
End
End If


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default How to test variable for chr values

Hi Smartin

not sure if I totally get the question


I think you got the question. I had forgotten about instr.
And it seems to be working.

Also, why so many chr() instead of plain text?

chr(67) chr(65) chr(68) chr(45) chr(82) is just strings C A D - R

I'm converting this from formulas, and that's the way the formulas
were set up. I changed it as you showed in your example.

Thanks,

Dan



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
can I test if a variable is a member of an array Andy Clarke Excel Programming 1 August 19th 08 04:30 PM
how to test whether selected variable is within defined range Abhinandan Excel Programming 0 May 26th 08 08:40 PM
Logical test as a variable in a UDF Dave Excel Programming 2 June 5th 06 09:59 PM
How to test if a workbook variable is valid Jean-Pierre Bidon Excel Programming 3 December 7th 05 04:37 PM
test for not blank, use value in cell and set as variable Robert Excel Discussion (Misc queries) 0 March 24th 05 11:25 PM


All times are GMT +1. The time now is 06:46 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"