+ Reply to Thread
Results 1 to 8 of 8

How to get select range that excludes hidden content?

  1. #1
    Forum Contributor
    Join Date
    03-29-2013
    Location
    US
    MS-Off Ver
    Office 2016
    Posts
    109

    How to get select range that excludes hidden content?

    A while back I got some great help here with how to work with a selected range. Pretty straightforward.

    Please Login or Register  to view this content.
    I'd like to do the same thing now, except exclude any hidden rows and columns. I also want to make sure that I can still loop over that range using simple for loops.

    Please Login or Register  to view this content.
    I'm guessing that each cell may also have a hidden/visible property that I could examine (haven't looked into it yet), but if I could just get a range that excludes those cells it would be much easier.

  2. #2
    Valued Forum Contributor PeteABC123's Avatar
    Join Date
    09-21-2012
    Location
    Chicago, IL
    MS-Off Ver
    MS Office 365 ver 2202
    Posts
    1,104

    Re: How to get select range that excludes hidden content?

    Highlight your range. F5 (go to) Special. Visible Cells Only. Click OK.

    Pete

  3. #3
    Forum Contributor
    Join Date
    03-29-2013
    Location
    US
    MS-Off Ver
    Office 2016
    Posts
    109

    Re: How to get select range that excludes hidden content?

    I'm sure that would work, but I'd prefer to keep the simple method of selecting the range that I've been using and handle it in code instead. If it's doable.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: How to get select range that excludes hidden content?

    set r = selection.specialcells(xlvisible)
    Ben Van Johnson

  5. #5
    Valued Forum Contributor PeteABC123's Avatar
    Join Date
    09-21-2012
    Location
    Chicago, IL
    MS-Off Ver
    MS Office 365 ver 2202
    Posts
    1,104

    Re: How to get select range that excludes hidden content?

    See protonLeah reply.

  6. #6
    Forum Contributor
    Join Date
    03-29-2013
    Location
    US
    MS-Off Ver
    Office 2016
    Posts
    109

    Re: How to get select range that excludes hidden content?

    Quote Originally Posted by protonLeah View Post
    set r = selection.specialcells(xlvisible)
    Thanks. Here's a problem I'm running into with that. The row and column counts for the selected range stop at the first hidden row or column.

    I'll see if I can explain. I select this range, with column D and rows 3 to 6 hidden. When I get the row and column counts, I get

    r.Rows.Count -> 2
    r.Colums.Count -> 3


    A B C E
    1 Joe Smith Mar 8, 1969 New York True
    2 Bob Jones Nov 17, 1984 California False
    7 Ed Connors Apr 14, 1983 Florida True
    8 Lisa Schrum May 9, 1959 New York False
    9 David Decker Jul 9, 1981 Minnesota True

  7. #7
    Forum Contributor
    Join Date
    03-29-2013
    Location
    US
    MS-Off Ver
    Office 2016
    Posts
    109

    Re: How to get select range that excludes hidden content?

    No ideas how I can loop over the cells within that range? Being able to select the range doesn't do me much good unless I can also work with the data.

  8. #8
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: How to get select range that excludes hidden content?

    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] COUNTIF formula that excludes hidden rows
    By Jnehra in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-22-2017, 12:50 PM
  2. Subtotal function that excludes hidden columns
    By kollur in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-01-2017, 06:18 PM
  3. I need to select a range and skip over the hidden columns
    By morangeman in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-06-2014, 09:29 PM
  4. Replies: 0
    Last Post: 01-15-2014, 05:17 PM
  5. [SOLVED] Select different range after opening a hidden file.
    By JO505 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-29-2013, 12:33 PM
  6. Replies: 3
    Last Post: 11-06-2012, 03:19 PM
  7. Select Range based on cell content
    By Brokovich in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2007, 06:56 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