Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default What is the proper dot.syntax to insert a select case within a With /End With Statement

For Instance,

Dim LRow As Long
Dim CostCode As String
Dim Vendor As String
With Sheets("Alpha")
LRow = Cells(Row,Count,1).End(xlUp).Row
Set CostCode = .Range("A2:A" & LRow).Value
Set Vendor = .Range("B2:B" & LRow).Value
Select Case CostCode
Case "<063" 'If CostCode is < "063" Numbers as Text
Do this
Case "304"
Do that
Case "386"
Select Case Vendor
Case "Martin"
Do This
Case "Charles"
Do That
End Select
End Select
End With
My syntax is approximative
Help appreciated,

J.P.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default What is the proper dot.syntax to insert a select case within a With / End With Statement

Try...

Dim LRow As Long
With Sheets("Alpha")
LRow = .Cells(.Rows.Count, 1).End(xlUp).Row
Select Case CLng(.Range("A2:A" & LRow).Value)
Case Is < 63 'If CostCode is < "063" Numbers as Text
'Do this
Case 304
'Do that
Case 386
Select Case .Range("B2:B" & LRow).Value
Case "Martin"
'Do This
Case "Charles"
'Do That
End Select
End Select
End With

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default What is the proper dot.syntax to insert a select case within aWith / End With Statement

Thank you Garry, but my cases are Alphas, not Numerics. "<063", "304", "386" etc...
..
Will the following statement change to handle Alphas ?
Select Case CLng(.Range("A2:A" & LRow).Value)
..
Thank you for your help.

J.P.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default What is the proper dot.syntax to insert a select case within a With / End With Statement

Thank you Garry, but my cases are Alphas, not Numerics. "<063",
"304", "386" etc... .


Not correct!
Your cases are 'numeric text', not alphas!

Will the following statement change to handle Alphas ?
Select Case CLng(.Range("A2:A" & LRow).Value)
.
Thank you for your help.

J.P.


Yes, it adapts your 'numeric text' so the Select Case works properly.
Note that this will only work if your value are 'numeric text', meaning
no alpha characters allowed.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #5   Report Post  
Banned
 
Posts: 6
Default

đọc truyện tranh rockin' heaven Thầy giáo : Em hăy cho biết Mặt Trăng xa hơn hay Mặt Trời xa hơn?
Tṛ : Mặt trời xa hơn ạ .
Th̀y : V́ sao ?
Tṛ : V́ sao của Khởi My ạ
Th̀y : ko, tại sao ?
Tṛ : Tại sao của Ưng Hoàng Phúc ạ !
Th̀y : Ko , ư th̀y là Why đó .!
Tṛ : Why ? À ! Why của DBSK .
Th̀y : Trời ơi ,tôi phải làm thế nào ? Xem thêm xem truyện tranh gay 18


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default What is the proper dot.syntax to insert a select case within aWith / End With Statement

How do I incorporate your statement
Select Case CLng(.Range("A2:A" & LRow).Value)

into my actual Select Case macro
Sub Test()
Dim LRow As Long
Dim rngC As Range
Dim myStr As String
With ActiveSheet
LRow = .Cells(Rows.Count, 1).End(xlUp).Row
For Each rngC In .Range("M3:M" & LRow)
Select Case rngC
Case Is < 63 '
myStr = Format(rngC, "000")
Format Error here when actual data can be 002, 063 or 386.
My Data type is 1
Thank you for your help.
J.P.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default What is the proper dot.syntax to insert a select case within a With / End With Statement

How do I incorporate your statement
Select Case CLng(.Range("A2:A" & LRow).Value)

into my actual Select Case macro
Sub Test()
Dim LRow As Long
Dim rngC As Range
Dim myStr As String
With ActiveSheet
LRow = .Cells(Rows.Count, 1).End(xlUp).Row
For Each rngC In .Range("M3:M" & LRow)


Select Case CLng(rngC.Value)

Case Is < 63 '
myStr = Format(rngC, "000")
Format Error here when actual data can be 002, 063 or 386.
My Data type is 1
Thank you for your help.
J.P.


--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


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
Select Case Syntax Minitman Excel Programming 12 January 19th 10 01:59 AM
Select Case syntax Alan Beban Excel Programming 14 July 15th 07 11:51 PM
syntax error in case statement? Janis Excel Programming 1 September 20th 06 06:22 PM
Syntax for Select Case Susan Hayes Excel Programming 4 November 30th 05 10:49 AM
Select Case syntax Susan Hayes Excel Programming 2 December 4th 04 10:42 PM


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