+ Reply to Thread
Results 1 to 8 of 8

How to select a row using contents of a cell

  1. #1
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    How to select a row using contents of a cell

    I am looking to select entire rows (Using code to go into a macro) based on partial contents of a cell. In the attached spreadsheet example I need to select the highlighted area. This is based on the first 4 characters in column A. i.e. the range is column A with the characters AB11 TO AB92. I have been asssuming that I need to use the "MID" function in some way but have failed miserably with each attempt I have made with creating the code (Probaly due to my lack of VBA skills and understanding of the MID function).
    If anyone could give some pointers it would be appreciated.

    (P.S. I asked a similar question in a different thread but over complicated it by putting in the next stage. I marked that thread as "SOLVED" and put in a comment to say I was going to start a new thread. Please advise if that is the correct way of handling it or should I have done it another way i.e. ask a moderator to close/delete the thread etc)
    Attached Files Attached Files
    Last edited by WasWodge; 10-31-2010 at 08:31 PM.

  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
    48,462

    Re: How to select a row using contents of a cell

    Where and how do you define the values to be selected? Are there always two? Or could there be three, four, whatever?

    If there are two values, would you want everything that is alphabetically/numerically within the range?

    Regards
    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
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: How to select a row using contents of a cell

    Values the selection is based on are always in column A and are always the 1st 4 digits (2 Letters and 2 Numbers). Basically they are the Aisle letters and the bay numbers in a warehouse (the last 3 digits are relate to shelf height and position and are irrelevant to the selection) and yes I need everything alphabetically then numerically in that selected range.
    They always run in that order if that is any help.
    If you mean the number of columns in the rows the various spreadsheets the macro will be used on is a maximum of 12.
    Last edited by WasWodge; 10-31-2010 at 01:43 PM.

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,785

    Re: How to select a row using contents of a cell

    Perhaps something like this?

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: How to select a row using contents of a cell

    Thanks Alf, the code above is working perfectly in the attached example but as I said in my second posting (This I think I was posting at about the same time as you were doing your posting), I need it to go as a range between AB11 and AB92 where as I think if I am reading the code correctly is selecting exactly AB11 and AB92. What do I have to alter in the coding to be a range? (Sorry about the poor description / test example).

  6. #6
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,785

    Re: How to select a row using contents of a cell

    Try replacing line

    Please Login or Register  to view this content.
    with

    Please Login or Register  to view this content.
    This should select numers from 11 to 92.

  7. #7
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: How to select a row using contents of a cell

    Thanks Alf. I wasn't thinkinking straight. I was over complicating it by thinking of merging the functions together under a range statement and over-looked just putting in a greater than/less than statement. I'll play around with the proper workbook tomorrow but can't see any reason why it won't work once I change the appropiate references so all solved. Thanks again
    Last edited by WasWodge; 10-31-2010 at 08:33 PM.

  8. #8
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,785

    Re: How to select a row using contents of a cell

    Perhaps changing the range from a static to a dynamic would be of more use.

    Please Login or Register  to view this content.
    HTH

    Alf

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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