+ Reply to Thread
Results 1 to 38 of 38

Help needed: Removing rows if it doesnt start with number

  1. #1
    Registered User
    Join Date
    05-24-2018
    Location
    Finland
    MS-Off Ver
    Office 365
    Posts
    11

    Help needed: Removing rows if it doesnt start with number

    Hello fellow users. I got a problem that i need solve, as fast as possible. I need to remove cells from A2 to A1000 which does not contain number at first character.

    I got this vba file already, that remove empty rows, but i still need some code to remove rows without number first.
    My A1 row is name which i dont want to be deleted.
    A2 row is 1234567-1
    A3 has -
    A4 has 1234567-2
    etc etc

    Here is that i use:

    Please Login or Register  to view this content.
    BR
    Aletzi1

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Help needed: Removing rows if it doesnt start with number

    How about:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Help needed: Removing rows if it doesnt start with number

    or
    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Help needed: Removing rows if it doesnt start with number

    Hi & welcome to the board.
    How about
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-24-2018
    Location
    Finland
    MS-Off Ver
    Office 365
    Posts
    11

    Re: Help needed: Removing rows if it doesnt start with number

    Hi, thanks for fast reply. Unfortunately xladept, it gives me syntax error... If Application.WorksheetFunction.CountA(Range("A" & i & ":" & "Z" & i)) = 0 _
    Or Val(Left(Range("A" & i),1)<>1 Then

    That line is red!

  6. #6
    Registered User
    Join Date
    05-24-2018
    Location
    Finland
    MS-Off Ver
    Office 365
    Posts
    11

    Re: Help needed: Removing rows if it doesnt start with number

    Quote Originally Posted by Fluff13 View Post
    Hi & welcome to the board.
    This is working like charm, is it possible to place this to my original code? TYVM FOR THIS CODE

  7. #7
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Help needed: Removing rows if it doesnt start with number

    How about
    Please Login or Register  to view this content.

  8. #8
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Help needed: Removing rows if it doesnt start with number

    Try it with the modified line.

    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  9. #9
    Registered User
    Join Date
    05-24-2018
    Location
    Finland
    MS-Off Ver
    Office 365
    Posts
    11

    Re: Help needed: Removing rows if it doesnt start with number

    The help here is something incredible. So i got now 3 vba files. They work when i use them in one by one. I would like to combine them in one if its possible (I can pay 5$ with paypal for the first working answer)

    First one removes all alphabetics exept 0 to 9 and - (I need this because i got some info from data scraping in these rows that starts like asd 1234567-4, that i need in my school project)
    Second one removes empty rows that i got from data scraping.
    Third one removes all the rows that wont start with numbers, like - and asd.

    Here is example of my rows in excel..
    A1 TEXT That i dont want to remove
    A2 1234567-1
    A3 asd 1234567-2
    A4
    A5 -
    A6 1234567-3
    A7 1234567-4
    A8 asd 1234567-5
    A9 asd asd asd
    A10 1234567-6
    A11
    A12
    A13 -


    The result that im looking for is like
    A2 1234567-1
    A3 1234567-2
    A4 1234567-3
    A5 1234567-4
    A6 1234567-5
    A7 1234567-6

    So no numbers lost, only alphabetics and empty rows ( and rows with only -)

    BR
    Aletzi
    Last edited by aletzi1; 05-24-2018 at 03:54 PM.

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Help needed: Removing rows if it doesnt start with number

    I forgot a parenthesis

    Please Login or Register  to view this content.

  11. #11
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Help needed: Removing rows if it doesnt start with number

    Sorry, I misread the OP, You want to keep numbers and deleted letters. Try this one.

    Please Login or Register  to view this content.
    BTW, no charge if it works. Not allowed on this site.
    Last edited by JLGWhiz; 05-24-2018 at 04:12 PM.

  12. #12
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Help needed: Removing rows if it doesnt start with number

    Quote Originally Posted by JLGWhiz View Post
    ...You want to keep numbers and deleted letters. Try this one ...
    It was enough to change it to " ... Like "[!0-9]" ..." ...

  13. #13
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Help needed: Removing rows if it doesnt start with number

    @ JLGWhiz,

    This will cost you $1000.00

    The OP wants the Code to Run from Row two. You don't have to specify lower case "a-z", and you may include other special characters like /, \, |, *,~,-.

    So your Code will look like this:

    Please Login or Register  to view this content.
    Now please pay up or else.

    Regards.
    Last edited by Winon; 05-24-2018 at 04:54 PM. Reason: Spelling!
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  14. #14
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Help needed: Removing rows if it doesnt start with number

    @Winon - Never could get the hang of the regex without using the handbook.

  15. #15
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Help needed: Removing rows if it doesnt start with number

    Wat kyk jy bakerman2?

    Hi there Buddy.

    Nice to see you so active!

    Regards.

  16. #16
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Help needed: Removing rows if it doesnt start with number

    Beware Tjaart, Big Brother is always watching you my man.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  17. #17
    Registered User
    Join Date
    05-24-2018
    Location
    Finland
    MS-Off Ver
    Office 365
    Posts
    11

    Re: Help needed: Removing rows if it doesnt start with number

    Dear Winom. This is working almost. But wont remove spaces before number and it wont remove text after numbers, if it be together with number, like

    A2 1234567-18asdasd
    A3 1234567-2

    Best regards
    Aletzi

  18. #18
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Help needed: Removing rows if it doesnt start with number

    Hello aletzi1,

    Welcome to this Forum.

    Do you want the results to be as shown below, and will it apply to Column A only?

    A2 1234567-18asdasd = 123456718
    A3 1234567-2 = 12345672

    Regards.

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

    Re: Help needed: Removing rows if it doesnt start with number

    Quote Originally Posted by aletzi1 View Post
    i still need some code to remove rows without number first.
    My A1 row is name which i dont want to be deleted.
    A2 row is 1234567-1
    A3 has -
    A4 has 1234567-2
    etc etc
    try
    Please Login or Register  to view this content.

  20. #20
    Registered User
    Join Date
    05-24-2018
    Location
    Finland
    MS-Off Ver
    Office 365
    Posts
    11
    Quote Originally Posted by Winon View Post
    Hello aletzi1,

    Welcome to this Forum.

    Do you want the results to be as shown below, and will it apply to Column A only?

    A2 1234567-18asdasd = 123456718
    A3 1234567-2 = 12345672

    Regards.
    Hi and thanks for replying. Column A only. I would like to result shown as

    A2 1234567-1asdasd =1234567-1
    A3 ASD1234567-2 =1234567-2
    A4 - = Delete row, because no numbers
    A5 "Empty row" = Delete this row
    A6 LETTERS ONLY = Delete this row

    So no letters, no spaces, no empty rows. I only need that - to be in the rows that has number on it, like seen on A2 and A3. So rows with - only, no need and can be deleted.

    I think this vba should first delete alphabetics, after that rows with only - and after this rows that are empty / has only spacebar on it i really dont have skills to do this by myself, this forum has helped me so much already. 😎

    Hope this clear out what i mean
    Last edited by aletzi1; 05-25-2018 at 02:05 AM.

  21. #21
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Help needed: Removing rows if it doesnt start with number

    Thank you for the clarification, aletzi1.

    Actually, your requirement has changed twice from the original Post, but here we go.

    Please Login or Register  to view this content.
    Please try the attachment, and enjoy.

    Regards.
    Attached Files Attached Files
    Last edited by Winon; 05-25-2018 at 02:47 PM.

  22. #22
    Registered User
    Join Date
    05-24-2018
    Location
    Finland
    MS-Off Ver
    Office 365
    Posts
    11

    Re: Help needed: Removing rows if it doesnt start with number

    Hi and thanks for huge help on my project. This is not still what i am looking for

    original.PNG
    This is what its looking original. I got about 70000 rows of this kind of information.

    inneed.PNG
    And this is how i need it to look.
    I can do this with 2 vba files that i already have, but i need to combine them into one working vba and i really got no skill. 5$ is still in the game
    Attached Images Attached Images
    Last edited by aletzi1; 05-26-2018 at 03:39 PM.

  23. #23
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Help needed: Removing rows if it doesnt start with number

    I don't get it - your original code with the fix as in Post #10 seems to work just fine

  24. #24
    Registered User
    Join Date
    05-24-2018
    Location
    Finland
    MS-Off Ver
    Office 365
    Posts
    11

    Re: Help needed: Removing rows if it doesnt start with number

    Quote Originally Posted by xladept View Post
    I don't get it - your original code with the fix as in Post #10 seems to work just fine
    Sorry, it does not work way it should.
    original.PNG

    After i run that code from post #10
    after.PNG

    It is missing 1656611-2, there is asd letters in 1656611-4 and its missing also 1656611-5.
    Attached Images Attached Images
    Last edited by aletzi1; 05-26-2018 at 03:54 PM. Reason: removing double photo

  25. #25
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Help needed: Removing rows if it doesnt start with number

    Hi aletzi1,

    Please try the revised attachment.

    Regards.
    Attached Files Attached Files

  26. #26
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Help needed: Removing rows if it doesnt start with number

    I'll give it one more shot.

    Please Login or Register  to view this content.
    Try this on your mock up sheet.

  27. #27
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Help needed: Removing rows if it doesnt start with number

    A little different than original:

    Please Login or Register  to view this content.

  28. #28
    Registered User
    Join Date
    05-24-2018
    Location
    Finland
    MS-Off Ver
    Office 365
    Posts
    11

    Re: Help needed: Removing rows if it doesnt start with number

    Quote Originally Posted by Winon View Post
    Hi aletzi1,

    Please try the revised attachment.

    Regards.
    This is it! This works way i mean it to work! Please contact me with pm (your paypal info)

  29. #29
    Registered User
    Join Date
    05-24-2018
    Location
    Finland
    MS-Off Ver
    Office 365
    Posts
    11

    Re: Help needed: Removing rows if it doesnt start with number

    Quote Originally Posted by JLGWhiz View Post
    I'll give it one more shot.

    Please Login or Register  to view this content.
    Try this on your mock up sheet.
    This removes asd 1656611-2, 1656611-5 and leaves text: 1656611-4asd
    Last edited by aletzi1; 05-27-2018 at 01:03 AM.

  30. #30
    Registered User
    Join Date
    05-24-2018
    Location
    Finland
    MS-Off Ver
    Office 365
    Posts
    11

    Re: Help needed: Removing rows if it doesnt start with number

    Quote Originally Posted by xladept View Post
    A little different than original:

    Please Login or Register  to view this content.
    This worked almost. Only thing was, it removed this row: asd 1656611-2
    Thank you for your help*!

  31. #31
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Help needed: Removing rows if it doesnt start with number

    Hi aletzi1,

    You are welcome, glad we could help. Just email me a Copy of $1000.00 note(bill).

    Thank for the Rep+.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Thanks.

  32. #32
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Help needed: Removing rows if it doesnt start with number

    Hello Hi aletzi1,

    I first wanted to get your approval on the basic approach on my latest sample Workbook, without error trapping. If you Click on the 'Click' Button after your Data has been cleaned you will receive an error message.

    To take care of that, please replace the Code in the sample Workbook with the Code below, as a "Fix".

    Please Login or Register  to view this content.
    Regards.

  33. #33
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Help needed: Removing rows if it doesnt start with number

    Thanks for the rep!

  34. #34
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Help needed: Removing rows if it doesnt start with number

    @ xladept,

    You stingy low whatever. I can't even compare you to a cockroach

    You are obliged to give me at least 75% of the Rep+, you have received.

    Thanks for your valuable contribution in this Thread, buddy.

    Kind regards.

  35. #35
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Help needed: Removing rows if it doesnt start with number

    @ Winon - Yeah, a cockroach can hold it's breath under water for an half-hour!

  36. #36
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Help needed: Removing rows if it doesnt start with number

    @ xladept,

    You are forcing me to set your hair on fire, so that you could slap yourself dead.

  37. #37
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Help needed: Removing rows if it doesnt start with number

    @ Fluff13,

    And what are you looking at?

  38. #38
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Help needed: Removing rows if it doesnt start with number

    @ Winon - Oh! No! You're too scary - I'm going to hide now

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Mail Merge code doesnt start SQL command
    By mmikem in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-14-2018, 06:32 PM
  2. [SOLVED] VBA Code to delete rows that do not start with a 5-digit number
    By slicky333 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-12-2016, 04:08 PM
  3. If else, If then statement needed when data doesnt exist ... help
    By Hondahawkrider in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-02-2015, 08:01 PM
  4. Replies: 13
    Last Post: 06-04-2015, 01:56 AM
  5. [SOLVED] Counting the number of used Rows and using this number to start a process
    By clabhart in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-23-2014, 10:15 AM
  6. Chart with Dual Axis and Line that doesnt start at 0
    By nickFe in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-14-2011, 04:56 AM
  7. removing rows featuring certain words (wildcards needed)
    By joe14 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-27-2008, 11:13 AM

Tags for this Thread

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