+ Reply to Thread
Results 1 to 5 of 5

Deleting cell contents starting with numbers VBA

  1. #1
    Registered User
    Join Date
    12-07-2018
    Location
    canada
    MS-Off Ver
    2018
    Posts
    30

    Deleting cell contents starting with numbers VBA

    I need a way to loop through cells in a specific column (eg. A) and check if they start with 5 or more numbers. If so I need to delete everything after the numbers end.

    So for example it will start like this
    4165460 ABC
    546445 SDF
    4654843354 FHD
    ABD 132
    1254 AHD


    And need it to end up like this
    4165460
    546445
    4654843354
    ABD 132
    1254 AHD

  2. #2
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,004

    Re: Deleting cell contents starting with numbers VBA

    Try:
    Please Login or Register  to view this content.

  3. #3
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,416

    Re: Deleting cell contents starting with numbers VBA

    Quote Originally Posted by sjk1193 View Post
    I need a way to loop through cells in a specific column (eg. A) and check if they start with 5 or more numbers.
    Is it ever possible that one or more of your 5+ digit numbers will start with a zero? If so, do you need to keep that leading zero?

  4. #4
    Registered User
    Join Date
    12-07-2018
    Location
    canada
    MS-Off Ver
    2018
    Posts
    30

    Re: Deleting cell contents starting with numbers VBA

    It may happen, just looking for the most robust solution, thanks

  5. #5
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,416

    Re: Deleting cell contents starting with numbers VBA

    Quote Originally Posted by sjk1193 View Post
    ...just looking for the most robust solution
    This macro will do what you want even if there is no space between the leading number and the text following it and it preserve leading zeros too...
    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)

Similar Threads

  1. [SOLVED] Move listbox contents to row, horizontally, starting at chosen cell.
    By IMM Tech in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-17-2021, 01:21 AM
  2. [SOLVED] SUMIF - sum the numbers in any cell starting with 'hh'.. ?
    By ashtally in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-05-2016, 07:35 AM
  3. Alert before deleting contents of a cell
    By DutyManager in forum Excel General
    Replies: 5
    Last Post: 02-27-2016, 11:28 PM
  4. Deleting cell contents within a range
    By aaron.irvine in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-16-2013, 08:16 PM
  5. Deleting rows containing certain text starting from an offset cell
    By hfrrtr100 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-05-2013, 10:35 AM
  6. When deleting cell contents, they come right back?
    By Paul987 in forum Excel General
    Replies: 3
    Last Post: 03-24-2008, 02:08 PM
  7. Replies: 2
    Last Post: 03-31-2007, 06:59 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