+ Reply to Thread
Results 1 to 10 of 10

Excel VBA to Select Multiple Range of Cells while in Filter Mode

  1. #1
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Question Excel VBA to Select Multiple Range of Cells while in Filter Mode

    Hi Everyone,

    I have this attached file, where Column G is filtered for certain Company.
    What I am trying to do by the VBA Codes:
    - Go to Cell A5,
    - then offset to next visible cell down the rows,
    - Select Range from Active Cell Selection.End(xlDown),

    I kind of managed until those steps,
    but I also need to select the Cells from Visible Row (in this case Row 29) Column - O, Selection.End(xlDown).Offset(0,4)
    how do i do this so that I would have selected two ranges A29:A63 & O29:R63 at the same time.
    Usually we do this by using ctrl manually selecting two ranges.
    Any help is appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Excel VBA to Select Multiple Range of Cells while in Filter Mode

    how do i do this so that I would have selected two ranges A29:A63 & O29:R63 at the same time.
    If I understand correctly ...First 5 visible rows...
    This is one way...
    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 star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Re: Excel VBA to Select Multiple Range of Cells while in Filter Mode

    No I am not looking for first 5 visible cells, rather I am looking to select all visible cells under the Current Filter (without the Header Row).
    The selection should be only in Columns A, O, P, Q & R

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Excel VBA to Select Multiple Range of Cells while in Filter Mode

    So why
    selected two ranges A29:A63 & O29:R63 at the same time
    So...Are you wanting all the visible rows after Header but only Columns(A, O, P, Q & R )

  5. #5
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Re: Excel VBA to Select Multiple Range of Cells while in Filter Mode

    yes, I ended up using the Below Codes but like to have a professional one written if possible:

    Dim X_TBAY As Integer
    Dim Y_TBAY As String
    Dim Z_TBAY As String
    Range("A5").Select
    Do
    ActiveCell.Offset(1, 0).Select
    Loop While ActiveCell.EntireRow.Hidden = True
    X_TBAY = ActiveCell.Row
    Range(Selection, Selection.End(xlDown)).Select
    Y_TBAY = Selection.Address
    Range("O" & X_TBAY).Select
    Range(Selection, Selection.End(xlDown).Offset(0, 3)).Select
    Z_TBAY = Selection.Address
    Application.Union(Range(Y_TBAY), Range(Z_TBAY)).Select

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Excel VBA to Select Multiple Range of Cells while in Filter Mode

    Please Login or Register  to view this content.
    PS...

    Please take a moment to read our forum rules...here
    Your post does not comply with Rule # 2
    2. Programming code must be enclosed in code tags to improve readability. (A, Z)
    Please Login or Register  to view this content.
    So...Edit your post...Highlight the code and press the # button

  7. #7
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Re: Excel VBA to Select Multiple Range of Cells while in Filter Mode

    Sorry about that:
    Please Login or Register  to view this content.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Excel VBA to Select Multiple Range of Cells while in Filter Mode

    All good...Tx...Next time you could just edit the post with the issue...

  9. #9
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Re: Excel VBA to Select Multiple Range of Cells while in Filter Mode

    wow that works like a charm
    I am just beginner in VBA, so I don't understand much from that.
    Thanks Anyway for your time and replies.

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Excel VBA to Select Multiple Range of Cells while in Filter Mode

    Glad I could assist..tx for marking thread as solved and tx for 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. [SOLVED] Mass Select Multiple Checkboxes in Excel Filter
    By Yoandsm in forum Excel General
    Replies: 1
    Last Post: 10-30-2019, 11:54 AM
  2. [SOLVED] Select multiple cells in range based on value
    By rpinxt in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-20-2017, 07:13 AM
  3. How to set Range in Filter mode and copy data using range value
    By Naveed Raza in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-12-2016, 12:18 PM
  4. [SOLVED] Multiple criteria in filter mode to delete
    By puuts in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2015, 12:34 PM
  5. Replies: 6
    Last Post: 01-03-2015, 03:27 PM
  6. Copy visible cells from Row B paste to Row A in filter mode
    By lakshmipathi123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-21-2012, 03:37 PM
  7. [SOLVED] Mouse sticks in select range mode
    By NaughtyMouse in forum Excel General
    Replies: 8
    Last Post: 11-05-2005, 09:35 PM

Tags for this Thread

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