+ Reply to Thread
Results 1 to 11 of 11

VBA to select next cell(s) with specific text

  1. #1
    Registered User
    Join Date
    04-18-2014
    Location
    Maryland
    MS-Off Ver
    2013
    Posts
    32

    VBA to select next cell(s) with specific text

    I'm working through a large data set that is a bit of a mess. The column I'm trying to deal with has a combination of client numbers and dates:

    12684632
    12/2/14
    1/23/15


    368543286
    11/3/14
    385498651
    11/2/14


    etc...

    I'm trying to figure out a way to find the next cell that contains a date (basically the next cell that contains a /), select it, and select all cells below that also contain a /, stopping when the next cell does not contain a /

    e.g. in the figure above starting at the top, the first two dates (12/2/14, 1/23/15) would be selected, then some other vba runs and does its thing (I've got this part working), then selects the next date (11/3/14), etc.

    Any help would be really appreciated. Thanks!

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: VBA to select next cell(s) with specific text

    Maybe something like this?

    Please Login or Register  to view this content.
    Martin

  3. #3
    Registered User
    Join Date
    04-18-2014
    Location
    Maryland
    MS-Off Ver
    2013
    Posts
    32

    Re: VBA to select next cell(s) with specific text

    Thanks for your help, but this doesn't seem to do anything for me. No error messages, nothing happens if I run it or go step by step. Am I missing something obvious?

  4. #4
    Valued Forum Contributor nigelbloomy's Avatar
    Join Date
    11-06-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    1,011

    Re: VBA to select next cell(s) with specific text

    Would this work for you?
    Please Login or Register  to view this content.
    Some people volunteer in soup kitchens or hospitals. I choose to make the world better by trying to help you with Excel. We're all learning.

    <---Click * Add Reputation for all helpful comments. It's like giving a smile.
    Forum Rules: How to mark your post [Solved] and have a happier, Excel enriched life.

  5. #5
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: VBA to select next cell(s) with specific text

    Can you post a copy of your workbook - I've made some assumptions about the layout which might not be correct.

  6. #6
    Registered User
    Join Date
    04-18-2014
    Location
    Maryland
    MS-Off Ver
    2013
    Posts
    32

    Re: VBA to select next cell(s) with specific text

    Here's a sample of the column I'm dealing with. The data in other columns is more client info. Due to the way the report is run, I can only get this data as plain text, meaning dates are formatted as text. That may be the problem.
    sample.xlsm

  7. #7
    Valued Forum Contributor nigelbloomy's Avatar
    Join Date
    11-06-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    1,011

    Re: VBA to select next cell(s) with specific text

    This would work if everything is text.

    Please Login or Register  to view this content.

  8. #8
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: VBA to select next cell(s) with specific text

    This seems to work for me.

    The code just selects the date ranges and them moves on so it all happens rather quickly - did you insert some code where indicated. Something like the line below will indicate what has happened if you turn the conditional formatting off.

    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to select next cell(s) with specific text

    Maybe:

    Please Login or Register  to view this content.
    Last edited by JOHN H. DAVIS; 06-16-2015 at 03:32 PM.

  10. #10
    Registered User
    Join Date
    04-18-2014
    Location
    Maryland
    MS-Off Ver
    2013
    Posts
    32

    Re: VBA to select next cell(s) with specific text

    Thanks to everyone for your input. Mrice, I got it to work. Not sure what the problem was but looks like user error on my end. This has saved me an immense amount of time!

  11. #11
    Valued Forum Contributor nigelbloomy's Avatar
    Join Date
    11-06-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    1,011

    Re: VBA to select next cell(s) with specific text

    This would also select all of the cells at once that are dates. It won't work if you have more than 8,000 non-contiguous cells. That is why the other codes looped through the sets of data.

    I coppied most of this from http://excelusergroup.org/forums/t/264.aspx

    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] select last row containing specific text in column
    By hopefulhart in forum Excel General
    Replies: 3
    Last Post: 06-01-2014, 07:11 AM
  2. Select Only specific text error msg on it not the right text
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-23-2014, 01:00 PM
  3. Replies: 3
    Last Post: 12-12-2013, 12:27 PM
  4. Select specific text from one cell and move to another cell
    By Cliffavon in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-02-2013, 04:08 AM
  5. Select cell containing specific text &return value from another ce
    By plf100 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-16-2005, 10:00 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