+ Reply to Thread
Results 1 to 11 of 11

VBA to highlight sequential numbers in dynamic column

  1. #1
    Registered User
    Join Date
    04-03-2025
    Location
    USA
    MS-Off Ver
    365
    Posts
    5

    VBA to highlight sequential numbers in dynamic column

    I have some spreadsheets we give to local service providers to list their employees and what services they are qualified to perform. However, sometimes when they fill in things like phone number, they use a company number and auto fill - and it fills as a series in error.

    We run a macro on every spreadsheet that comes back in to verify all required information is present, but it doesn't catch when this happens.

    The issue is that each spreadsheet is formatted different, so the phone number field isn't always in the same column - so I need a macro that will run based on the column header - not on the column letters.

    I've tried and can't figure it out. Is this something that's even possible...to locate the phone number header and look down to highlight sequential numbers? The phone number is in a number format already, so I'm hoping it's something we can do so we don't have to keep checking manually.

    Thanks!

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,081

    Re: VBA to highlight sequential numbers in dynamic column

    Without seeing what your data looks like, it's hard to suggest a solution. Assuming that the column header is "Phone Number" and that it is located in row 1, this macro will give you the column number.
    Please Login or Register  to view this content.
    It would be easier to help if you could attach a copy of your file so we could see how your data is organized and test possible solutions. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary). See the yellow banner at the top of this page for instructions to attach a file.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    04-03-2025
    Location
    USA
    MS-Off Ver
    365
    Posts
    5

    Re: VBA to highlight sequential numbers in dynamic column

    I've attached a copy of the blank template. This is just one of them, the phone number is in Column I, but on others it's in different columns and I was hoping to avoid having to create a separate macro for each one. Thank you!

    Directory Maintenance - v2.2.xlsx

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,533

    Re: VBA to highlight sequential numbers in dynamic column

    We can't do much with an empty file. Fill in the phone number column with fictuous numbers and highlight them manually so we can see what you're after.
    The code Mumps1 provided is for localizing the Phone number column which you can use in the rest of the needed code.
    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.

  5. #5
    Registered User
    Join Date
    04-03-2025
    Location
    USA
    MS-Off Ver
    365
    Posts
    5

    Re: VBA to highlight sequential numbers in dynamic column

    Apologies...I've attached a populate sample, thank you

    Sample Directory Maintenance - v2.2.xlsx

  6. #6
    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
    49,023

    Re: VBA to highlight sequential numbers in dynamic column

    Do you really need VBA for this? You could highlight the entire range from cell A2 down and across and use the Conditional Formatting formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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


  7. #7
    Registered User
    Join Date
    04-03-2025
    Location
    USA
    MS-Off Ver
    365
    Posts
    5

    Re: VBA to highlight sequential numbers in dynamic column

    That's definitely an option if it would work best. This is just a sample, sometimes these listings have six to twelve thousand lines, and our spreadsheets have between 10 and 100 columns depending on the types of service providers we are sending them to...I assumed that conditional formatting to an entire spreadsheet when there could be that many rows on there would cause issues?

  8. #8
    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
    49,023

    Re: VBA to highlight sequential numbers in dynamic column

    If you really want VBA, this applies the rule described previously.

    Please Login or Register  to view this content.

  9. #9
    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
    49,023

    Re: VBA to highlight sequential numbers in dynamic column

    OK, applied to one column.

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    04-03-2025
    Location
    USA
    MS-Off Ver
    365
    Posts
    5

    Re: VBA to highlight sequential numbers in dynamic column

    That worked! Thank you so much!!

  11. #11
    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
    49,023

    Re: VBA to highlight sequential numbers in dynamic column

    You're welcome. Thanks for the rep.

+ 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. how to highlight more than one column after non sequential number/Date?
    By FakeFace in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-14-2023, 01:28 PM
  2. [SOLVED] VBA code for sequential numbers for a column containing letters and numbers
    By YuriyBaron in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2018, 10:03 PM
  3. [SOLVED] Fill Series of Sequential Numbers in Column A Based on Last Value in Column B - VBA
    By CC268 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-24-2017, 01:09 PM
  4. Macro to add a column of sequential numbers
    By scruz9 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-23-2014, 02:42 PM
  5. Adding Sequential Numbers in Column B Based on Column A Values
    By habsfan1433 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-14-2014, 04:17 PM
  6. Sequential column numbers
    By C Holmes in forum Excel General
    Replies: 2
    Last Post: 06-04-2010, 01:45 PM
  7. Sequential Numbers Depending on Another Column
    By hardeep.kanwar in forum Excel General
    Replies: 4
    Last Post: 12-06-2009, 07:37 AM

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