+ Reply to Thread
Results 1 to 3 of 3

Look for a number starting with a partcular sequence of digits

Hybrid View

  1. #1
    Registered User
    Join Date
    01-23-2009
    Location
    Chicago
    MS-Off Ver
    Excel 2003
    Posts
    58

    Look for a number starting with a partcular sequence of digits

    Hi,
    What I have here is a code which looks for a number starting with 410, moves to another cell and autofills it. Does anyone know how can it be modified so that it will look for a number starting with 410 as well as 430 or any number starting with 4?
    Thanks.

    Sub MovePO()
    Dim Cell As Range
    Dim Num As String
    
    Set Cell = Range("B1")
    Do Until Cell = "END OF REPORT"
    Select Case Left(Cell.Value, 3)
    Case "410"
    Num = Cell.Value
    Cell.Value = ""
    Case Is <> ""
    Cell.Offset(0, -1).Value = Num
    End Select
    If Cell.Row = Rows.Count Then
       MsgBox "Last Row on Sheet Reached"
       End
    End If
    Set Cell = Cell.Offset(1, 0)
    Loop
    End Sub

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Look for a number starting with a partcular sequence of digits

    Change
    Select Case Left(Cell.Value, 3)
    to
    Select Case Left(Cell.Value, 1)
    and
    Case "410"
    to
    Case "4"
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    01-23-2009
    Location
    Chicago
    MS-Off Ver
    Excel 2003
    Posts
    58

    Re: Look for a number starting with a partcular sequence of digits

    I tried that, it returns a value of 4 instead of the entire 10 digit number...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1