+ Reply to Thread
Results 1 to 6 of 6

delete the rest of the row if found more than two spaces

  1. #1
    Registered User
    Join Date
    12-10-2008
    Location
    portugal
    Posts
    24

    delete the rest of the row if found more than two spaces

    hello

    I'm looking for a vba to delete the rest of row if found more that two spaces
    example
    UV4003K 0.01% 31750 kg/hr 3,175 kg/hr 52.91666667 --> UV4003K 0.01% 31750 kg/hr 3,175 kg/hr

    the same for all rows

    is it possible ?

    thank you

    ccruz

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: delete the rest of the row if found more than two spaces

    If you mean find 2 consecutive spaces, then this would do it

    intRowCount = 1
    Do until range("A" & intRowCount).value =""
    intTwoSpace = instr(1,range("A" & intRowCount).value,string(2,32))
    if intTwoSpace >0 then
    range("A" & intRowCount).value = trim(mid(range("A" & intRowCount).value,1,intTwoSpace))
    end if
    intRowCOunt=intRowCOunt+1
    loop

    If you wanted to delete everything after the 2nd non consecutive space, try


    intRowCount = 1
    Do until range("A" & intRowCount).value =""
    intTwoSpaceFI = instr(1,range("A" & intRowCount).value,chr(32))
    intTwoSpaceSI = instr(intTwoSpaceFI ,range("A" & intRowCount).value,chr(32))
    if intTwoSpaceSI >0 then
    range("A" & intRowCount).value = trim(mid(range("A" & intRowCount).value,1,intTwoSpaceSI))
    end if
    intRowCOunt=intRowCOunt+1
    loop


    I wrote these in notepad, not in VBA, so may need a bit of tweaking.

  3. #3
    Registered User
    Join Date
    12-10-2008
    Location
    portugal
    Posts
    24

    Re: delete the rest of the row if found more than two spaces

    the first is perfect thank you

    is it possible find and delete large numbers .
    example in a spreadsheet find and delete numbers graeter than 10000 ?

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: delete the rest of the row if found more than two spaces

    Very similar
    http://www.excelforum.com/excel-prog...wo-spaces.html

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-10-2008
    Location
    portugal
    Posts
    24

    Re: delete the rest of the row if found more than two spaces

    sorry. my question was find and delete numbers with more than 5 characters AFTER two spaces

    thank you
    ccruz

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: delete the rest of the row if found more than two spaces

    Quote Originally Posted by ccruz View Post
    sorry. my question was find and delete numbers with more than 5 characters AFTER two spaces

    thank you
    ccruz
    Please Login or Register  to view this content.

+ 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