+ Reply to Thread
Results 1 to 1 of 1

Saving ranges into dictionary to then reorder and paste onto another worksheet

  1. #1
    Registered User
    Join Date
    09-11-2018
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    1

    Saving ranges into dictionary to then reorder and paste onto another worksheet

    Hi guys,

    Firstly, although I have just joined this forum, I have been visiting this forum as a passive user for a few years now.
    I would just like to say thank you in advance for all of the problems this community has already solved for me simply by answering other's issues.
    The dedication of some members is truly amazing, and the apathy of some posters is equally astounding.

    I am trying to save dynamic ranges into a scripting dictionary to simply paste back onto a worksheet.
    I already have 90% of my code working (which is quite involved, I'll try not to bog this down too much)

    Scenario:
    I have a spreadsheet that renders staff rosters over a user selected date and date range (from one week to say 6 weeks)
    User's have their own row (say 140 staff) and the days are listed chronological as columns left to right.
    Each 'day' is actually 24 columns so I can render their shifts in a 'Gantt' chart style across each day.
    This shows midnight crossings, double shifts, rest periods etc.....

    The saved ranges within the dictionary contain merged cells, values, borders, colours and cell comments.
    Each staff member has a unique ID and has only one row. This all works nicely so far.

    So I have several dictionaries that I reference to build and rebuild the sheet each time.
    I say rebuild because I also have the option for the user to select a date (by selecting that 'day' onscreen - Workbook_SheetSelectionChange)
    By doing so, I reorder a specific dictionary for that day, reorder the staff ID's and want to redraw the sheet showing the sorted shifts for the selected day.
    Which shift starts first, who is on first shift and so on,

    Rendering the initial sheet take a little bit of time (workbook actually loads external data, builds several dictionaries - so user can wait for this),
    But redrawing the sorted results I think should be faster considering I already have all of the data stored in memory.

    I can redraw the sheet from the sorted data no problem, but rendering it takes too long to redraw (in my opinion) and ruins the user experience.

    My idea was
    + copy each staff member's entire row as a range (which already has all the shift information, colours, cell comments etc) into a dictionary - (already done) - uses staff ID as the key
    + reorder the shifts as required and save a new listing of staff ID's based on the required order - (already done)
    + use this reordered staff list to paste their saved ranges back onto the worksheet (staff ID reordering for the selected day will display the sorted shifts as required)

    I am just having some trouble extracting the saved range back onto the sheet, it doesn't reproduce the initial range.
    Now I should say, copying ranges from one worksheet to another or even from one workbook to another is no problem, the issue *seems* to be the dictionary.

    I must be missing something...

    This is my code to build the Staff Ranges...

    Please Login or Register  to view this content.

    And to 'redraw' them onto a worksheet... (sheet has been cleared, new listing of staff IDs with required order has been prepared)

    Please Login or Register  to view this content.
    Finally, the target sheet will always be the same size (in that usedrange.columns.count will be the same)

    any ideas?

    Thanks in advance..
    Baldric
    Last edited by Baldric; 09-12-2018 at 12:05 AM.

+ 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] Join 3 arrays/arraylist/ranges and pass them to dictionary
    By jaryszek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-09-2018, 07:49 AM
  2. Replies: 4
    Last Post: 10-12-2015, 01:44 PM
  3. Copy and paste different ranges from a worksheet into a new workbook
    By bigpappi23 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-06-2013, 08:47 AM
  4. Replies: 2
    Last Post: 01-03-2013, 01:29 AM
  5. Copy / Paste multiple loop results in specific column ranges on one worksheet
    By bfbisso in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-24-2012, 01:11 PM
  6. Replies: 3
    Last Post: 06-16-2010, 04:23 PM
  7. Dictionary and saving workbook/ reopening
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-30-2006, 12:30 AM

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