+ Reply to Thread
Results 1 to 7 of 7

Removing rows containing Alpha characters in column B

  1. #1
    Registered User
    Join Date
    02-09-2022
    Location
    RI, USA
    MS-Off Ver
    2016
    Posts
    3

    Thumbs up Removing rows containing Alpha characters in column B

    Hello,

    The following code (credit Tushar Mehta) works great for deleting a row if a cell in column B contains and alpha character at the beginning or end, however it is not deleting if one or more alpha characters are mixed in- example 123B456H87

    How could the code be adjusted to delete based on finding an alpha character anywhere in the cell?

    Please Login or Register  to view this content.
    Last edited by AliGW; 02-10-2022 at 10:24 AM. Reason: Tagged as solved - no need to edit the thread title!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,529

    Re: Removing rows containing Alpha characters in column B

    Can't see it would make a difference where the alpha characters are … it wouldn’t be numeric, full stop.

    A B C D E F
    123B456H87 FALSE =ISNUMBER(B2) TRUE =ISTEXT(B2)
    A12345 FALSE =ISNUMBER(B3) TRUE =ISTEXT(B3)
    56789B FALSE =ISNUMBER(B4) TRUE =ISTEXT(B4)
    12345 TRUE =ISNUMBER(B5) FALSE =ISTEXT(B5)
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    02-09-2022
    Location
    RI, USA
    MS-Off Ver
    2016
    Posts
    3

    Re: Removing rows containing Alpha characters in column B

    I am not a skilled user, but agree did not see anything in the code that would only delete leading/trailing. Attached a test book, tripled the sample set and that resulted in the same alpha-numeric cell failing to delete.
    Attached Files Attached Files

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,529

    Re: Removing rows containing Alpha characters in column B

    OK, there is clearly a difference between VBA IsNumeric and woksheet ISNUMBER

    IsNumber checks if a value is stored as a number. Whereas, IsNumeric checks if a value can be converted into a number.

    For example, if you pass a blank cell as a parameter, IsNumber will return FALSE, while IsNumeric will return TRUE. Also, if you pass a cell containing number stored as a text, IsNumber will return FALSE and IsNumeric TRUE.
    Quote courtesy of: https://www.automateexcel.com/vba/is...0return%20TRUE.

    That said, I can't understand what is happening here.

    I have added some Debug.Print statements to monitor the loop. I have also replaced IsNumeric (Alpha) with Application.WorksheetFunction.IsNumber (Beta_TMS).

    The latter version works as expected ...

    Please Login or Register  to view this content.
    PHP Code: 
    [FONT=Courier New]
    Alpha
    processing row
    :              10           24943E        True
    deleting row
    :                10           24943E
    processing row
    :              9            E20097136     True
    deleting row
    :                9            E20097136
    processing row
    :              8            20554D8       False
    processing row
    :              7            24943E        True
    deleting row
    :                7            24943E
    processing row
    :              6            E20097136     True
    deleting row
    :                6            E20097136
    processing row
    :              5            20554D8       False
    processing row
    :              4            24943E        True
    deleting row
    :                4            24943E
    processing row
    :              3            E20097136     True
    deleting row
    :                3            E20097136
    processing row
    :              2            20554D8       False
    Beta
    processing row
    :              4            20554D8       True
    deleting row
    :                4            20554D8
    processing row
    :              3            20554D8       True
    deleting row
    :                3            20554D8
    processing row
    :              2            20554D8       True
    deleting row
    :                2            20554D8
    [/FONT

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

    Re: Removing rows containing Alpha characters in column B

    kayakindude,

    IsNumeric function has a known bug.
    You can see all those returns True
    Please Login or Register  to view this content.
    1) Loop
    Please Login or Register  to view this content.
    2) no loop
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-09-2022
    Location
    RI, USA
    MS-Off Ver
    2016
    Posts
    3

    Re: Removing rows containing Alpha characters in column B

    Thank you for the feedback and examples, went with the loop sample, which gave me fits until I figured out it needed to be in it's own module and called by the main macro. Thanks again!

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,529

    Re: Removing rows containing Alpha characters in column B

    Who are you thanking? And which loop sample are you referring to?

+ 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] Removing blank rows + alpha sort
    By AlexanderWeb in forum Excel General
    Replies: 7
    Last Post: 11-10-2020, 01:31 PM
  2. [SOLVED] Removing alpha characters from a string with multiple telephone numbers
    By JKDSki in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-31-2018, 08:55 PM
  3. [SOLVED] Removing Chinese characters from certain rows in a column
    By KSChan in forum Excel General
    Replies: 11
    Last Post: 12-14-2016, 12:24 AM
  4. Format column with both alpha and numeric characters
    By wsykes41770 in forum Excel General
    Replies: 3
    Last Post: 10-01-2014, 11:15 AM
  5. Removing alpha in column in excel
    By tonyradstone in forum Excel General
    Replies: 4
    Last Post: 12-08-2011, 08:51 AM
  6. Removing Alpha characters formula
    By will.00 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-24-2007, 04:13 AM
  7. [SOLVED] Not allowing Alpha Characters in a Numeric Formatted Column
    By CaptainBly in forum Excel General
    Replies: 5
    Last Post: 02-28-2006, 06:10 PM

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