Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 26 of 26

Thread: Delete all rows that don't start with CRN or AT

  1. #21
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,478
    Location
    You just have to contribute answers to a few thousand questions and you pick up a bit of knowledge along the way! ...or you could buy a book.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  2. #22
    VBAX Regular rrtts's Avatar
    Joined
    Sep 2006
    Posts
    61
    Location
    Never mind...figured it out.

  3. #23
    VBAX Regular rrtts's Avatar
    Joined
    Sep 2006
    Posts
    61
    Location
    @MD - I ran into a bit of a snag I'm hoping you can help me with...

    Can you explain your "Split Text" code - the problem I am having is that if there are multiple words then it deletes some of the text...

    For example,

    If the text is:

    RHHIDEF/UNIT 2 (all in one cell), the result is RHHIDEF UNIT 2 (all in different cells - which is perfect).

    But if the text is

    RHHIDEF/UNIT 2 A B C (all in one cell), the result is RHHIDEF UNIT 2 (all in different cells - but A B C is deleted - which is bad).

    Any ideas...thanks.

    (Do you have any recommendations on Excel Books - I'm hesitant to just get the Excel 2003 for Dummies - but it might best fit my level of knowledge...heh heh).

  4. #24
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,478
    Location
    Split creates an array of items as defined by the delimiter so
    Arr = Split(RHHIDEF/UNIT 2 A B C,"/") will form a 2 item array
    Arr(0) = RHHIDEF
    Arr(1) = UNIT 2 A B C
    The second bit of the code will split UNIT 2 A B C into 5 items using Space as a delimiter. If you want the A B C in a separate cell. you would need to concatenate these array items with spaces to reform the string.

    You need to be sure of your data make up before you can write code to handle it.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #25
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Quote Originally Posted by mdmackillop
    ...or you could buy a book.
    If only it were that easy.
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  6. #26
    VBAX Regular rrtts's Avatar
    Joined
    Sep 2006
    Posts
    61
    Location
    @MD...great!

    Your original code was:

    [vba]
    Sub SplitText()
    Dim cel As Range
    For Each cel In Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
    arr = Split(cel, "/")
    If InStr(1, cel, "/") = 0 Then Goto Skipped
    cel = arr(0)
    cel.Offset(, 1) = Split(arr(1), " ")(0)
    cel.Offset(, 2) = Split(arr(1), " ")(1)
    Skipped:
    Next
    End Sub
    [/vba]

    After tinkering with it and your tips...I realized that once I deleted the 2nd cel.Offset I achieved the desired results.

    It's amazing how simple this all seems once someone shows it to you...I feel dumb asking some of the questions I do only to realize a simple tweak gets the job done.

    I do appreciate all the help...again.

    @Ken Puls - Amen. I go to the local book store and try and read thru various books (like I know what I'm doing heh heh)...there are SO many books on the subject I need a book just to explain all the other books.

Posting Permissions

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