Consulting

Results 1 to 3 of 3

Thread: Formula Help

  1. #1

    Formula Help

    I could use some help creating a statemtent that loops through a range and says:
    Loop through the range in col. I and delete the first word and first space in the string of that cell in Col I.

    example:
    Autobahn Dual Wht. 52

    would become

    Dual Wht. 2

    Thanks,

    Doug
    my site: www.ecboardco.com
    was built w/ a majority of the assistance from the board members here... thanks VBAX.

    Just because I see something, doesn't mean that what's actually happening is what I see.

    You don't get from 0-90 by standing still!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You can't do it with a formula in one move Doug.

    What you can do is in an adjacent column use

    =IF(ISNUMBER(FIND(" ",A2)),MID(A2,FIND(" ",A2)+1,255),A2)

    copy that down.

    You could then copy > Paset values on that column and delete the original
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Expert
    Joined
    Feb 2005
    Location
    Nanaimo, British Columbia, Cananda
    Posts
    568
    Location
    Hi Doug,

    Code an option?

    [VBA]
    Option Explicit
    Sub DelSpace()
    Dim cel As Range
    Dim Rng As Range
    Dim SpcCtr As Long
    Dim Str2 As String
    Dim LastRow As Long
    'Speed
    Application.ScreenUpdating = False
    'Get Last Row of data
    LastRow = Range("I" & Rows.Count).End(xlUp).Row

    'Presumes Col I data starts in row 2
    Set Rng = Range("I2:I" & LastRow)

    'Do all
    For Each cel In Rng
    'Clean cell of extra (leading & trailing) spaces
    cel = Trim(cel)
    'Get position of first space character
    SpcCtr = InStr(cel, " ")
    'Check if space was found
    If SpcCtr > 1 Then
    'Write cell value minus first word&space
    cel = Right(cel, Len(cel) - SpcCtr)
    End If
    'Clean cell of extra (leading & trailing) spaces
    cel = Trim(cel)
    Next cel

    'Reset
    Application.ScreenUpdating = False

    'Clean memory
    Set cel = Nothing
    Set Rng = Nothing
    End Sub

    [/VBA]

    Dusty
    Cheers,

    dr

    "Questions, help and advice for free, small projects by donation. large projects by quote"

    http:\\www.ExcelVBA.joellerabu.com

Posting Permissions

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