+ Reply to Thread
Results 1 to 10 of 10

Select All Headers with Same Name, Select All Cells Below

  1. #1
    Registered User
    Join Date
    11-29-2018
    Location
    New Brunswick, Canada
    MS-Off Ver
    2013
    Posts
    18

    Select All Headers with Same Name, Select All Cells Below

    Good afternoon,

    I have a spreadsheet with around 100 columns. One of the column headers, "case", is found multiple time. What I want to do is select all of the cells below each of these headers (down to the last cell with value). I did manage to do enough research to use VBA to select each iteration of the "case" header, but I'm not sure where to go now. I'm assuming I need to use the offset to drop down a row to the first cell with a value, and then use a range with x1Down, but nothing I do seems to work.

    Any and all help is appreciated!

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,299

    Re: Select All Headers with Same Name, Select All Cells Below

    Try a macro like this, assuming your headers are in row 1:

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Select All Headers with Same Name, Select All Cells Below

    Here's a non looping option...
    Please Login or Register  to view this content.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,299

    Re: Select All Headers with Same Name, Select All Cells Below

    I had to re-write your select line to this - the .currentregion was selecting all columns

    Please Login or Register  to view this content.

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Select All Headers with Same Name, Select All Cells Below

    Perhaps a version issue...Works for me...

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,299

    Re: Select All Headers with Same Name, Select All Cells Below

    Excel 2016 - If I use this within the With

    Msgbox Range(Join(X, ",")).CurrentRegion.Address

    I get the same as

    Msgbox .Address

    so the .currentregion is undoing the specifics of Range(Join(X, ","))

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,700

    Re: Select All Headers with Same Name, Select All Cells Below

    Re Bernie's comment Post #4.
    Same here in Excel 2007

  8. #8
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Select All Headers with Same Name, Select All Cells Below

    Managed to test...you guys are correct...Thanks for code correction Bernie...
    Last edited by Sintek; 06-22-2021 at 06:42 AM.

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,299

    Re: Select All Headers with Same Name, Select All Cells Below

    Quote Originally Posted by sintek View Post
    Perhaps a version issue...Works for me...

    Managed to test...you guys are correct...
    You're welcome, but you are too good to post untested code

  10. #10
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Select All Headers with Same Name, Select All Cells Below

    Old age...I guess...lol
    Sometimes busy with so many threads and solutions at once...

+ 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. Replies: 11
    Last Post: 04-19-2021, 07:46 PM
  2. Importing select data from Notepad to Excel, but not repeated headers
    By CaseyH in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-31-2017, 01:38 PM
  3. [SOLVED] How to select 3 cells, transpose, loop to select next 3 cells.
    By Hood in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-02-2017, 02:07 PM
  4. [SOLVED] User-Form Problem: User can select headers in User Form (I want Header/no way to select)
    By navialivad in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-18-2014, 10:24 AM
  5. Replies: 3
    Last Post: 04-11-2013, 04:13 AM
  6. [SOLVED] How to select from a table of values based upon column and row headers
    By Peteryoull in forum Excel General
    Replies: 4
    Last Post: 07-30-2012, 05:58 AM
  7. Print column headers on select pages only
    By RonJ in forum Excel General
    Replies: 3
    Last Post: 03-07-2012, 09:00 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