+ Reply to Thread
Results 1 to 14 of 14

Store visble databodyrange in filtered table into an array

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Store visble databodyrange in filtered table into an array

    Hello everyone
    I am trying to store the filtered visible rows of a table but I encountered an error
    This is the code I am trying to use
    Please Login or Register  to view this content.
    and this is the error
    001.png
    Any idea how to fix that?
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,913

    Re: Store visble databodyrange in filtered table into an array

    Unprotect the sheet before this piece of code then protect it again after.

    Or, set the protection with UserInterfaceOnly = True in the workbook open event so that the VBA can act on the sheet with it still protected.

    BSB

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Store visble databodyrange in filtered table into an array

    Thanks a lot for pointing out that .. but the array still not correct ..
    Please Login or Register  to view this content.
    The array shows only two rows of the filtered data and one column !!
    Help.png

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Store visble databodyrange in filtered table into an array

    Any help in this topic please?

  5. #5
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,913

    Re: Store visble databodyrange in filtered table into an array

    Easier to to help if we can see the workbook. Can you attach it?
    Anonymize any sensitive data first.

    BSB

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Store visble databodyrange in filtered table into an array

    Here's a sample workbook
    Attached Files Attached Files

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Store visble databodyrange in filtered table into an array

    Hi Yasser,

    This works on the unprotected sheet:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Store visble databodyrange in filtered table into an array

    Thanks a lot my friend
    But I need to store the data inside the table only (only visible rows in the table) ..
    The sheet has other data ..
    That's a point.

    Another point as for your code it deals with the hidden rows too and this is not desired
    And when I tried to add this line I got an error(424) : Object required
    Please Login or Register  to view this content.

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Store visble databodyrange in filtered table into an array

    Hi Yasser old friend,

    Where do you want to store the data?

    Please Login or Register  to view this content.
    Last edited by xladept; 04-14-2018 at 01:55 PM.

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Store visble databodyrange in filtered table into an array

    Thanks a lot for solution
    Is there a way to avoid the copy part and store directly the databodyrange of the table ..!! I expect there is a way and I have googled a lot but with no luck

  11. #11
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Store visble databodyrange in filtered table into an array

    I thought of a way by converting the table to range then converting the range again to table
    I used this line to convert the table to range
    Please Login or Register  to view this content.
    But the problem is that I lose the filtering process after converting ..
    So is there a way to keep the filtered data after converting?

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Store visble databodyrange in filtered table into an array

    Hi Yasser,

    Thanks for the rep!

    This seems to work:

    Please Login or Register  to view this content.
    Last edited by xladept; 04-15-2018 at 12:08 AM.

  13. #13
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Store visble databodyrange in filtered table into an array

    Thank you very very much my friend. I appreciate a lot your help

    It seems there is no way escaping the loops (and this cause slow in execution as the original data is too large)
    Generally the thread will be open for others to share their ideas
    Thanks a lot for great help

  14. #14
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Store visble databodyrange in filtered table into an array

    You're welcome old friend, probably establishing a worksheet array on a temporary sheet would be the quickest

+ 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] Pivot Table DataBodyRange for a dynamic range selection in Cell Formula
    By SMCC in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-04-2018, 01:57 PM
  2. [SOLVED] Excel Table: find sum of databodyrange
    By snapfade in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-08-2017, 07:20 PM
  3. [SOLVED] Dynamic Changing Data, Based on Criteria Store in Array, Sum array and store in Cell
    By penbeacho in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-28-2015, 10:31 AM
  4. Can I store an array of data within a table?
    By krabine in forum Access Tables & Databases
    Replies: 3
    Last Post: 01-14-2015, 12:04 PM
  5. Copy table DataBodyRange to another table Loop
    By jockywilson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-19-2014, 11:38 AM
  6. Replies: 25
    Last Post: 01-24-2013, 06:07 AM
  7. Count nullstrings in pivot table (databodyrange)
    By jonasmj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2005, 10:06 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