+ Reply to Thread
Results 1 to 2 of 2

Need to paste a variant array in numeric order

  1. #1
    Registered User
    Join Date
    07-18-2024
    Location
    United States
    MS-Off Ver
    MS 365
    Posts
    39

    Need to paste a variant array in numeric order

    I have been helping a team with automating their sheet and got like 98% of the way there and realized that I don't think I can use the method I utilized to get the 98%. Basically in the matrix file users are filling out info in sheet 1 columns A & B. I wanted to have the macro generate the entirety of sheet 2 and the last column on sheet 3. You can see from the macro that everything works EXCEPT row 2 on sheet 2. When I create the table it starts with headers, and then when those are deselected it moves the table. In the process of fixing this by just moving the table I realized i used arbitrary numbers when defining the columns of the table, I figured id use the rowcount of sheet 3 to define the columns of the table and realized that sheet 3 has over 100 rows and sheet 2 does not have the same number of columns. This indicated to me that the team was creating new columns in sheet 2 as they found something that would match sheet 3. The issue is that sheet 3 will expand.

    I figured I would add the title of the columns of sheet 2 from scratch by creating a title for every unique ID that appears in column B of sheet 1 (the one the users fill out)
    I have gotten this code so far

    Please Login or Register  to view this content.
    the variable data is a variant array with each unique ID and the count of those unique instances, the issue being that it stored them in the order they appeared and if you look at the non xslm sheet, these need to be in order. To make matters worse, some ID's are numeric and some are text "i, ii, iii, iv, N/A" etc. I do not think it is going to be an issue if the text is placed before or after the numbers but I am at my limit of VBA knowledge trying to figure out a good way to paste the values of data into the columns of sheet 2 in order. Does anyone have any tips?


    EDIT: 3/7/25 3:42 pm MST
    I ended up adding this to the end of my code and it worked. Posting here in case anyone else wants to use it or has a better idea
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by MDLovitt; 03-07-2025 at 06:55 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,223

    Re: Need to paste a variant array in numeric order

    If that's fast enough for you, it's fine. If you find it to be slow, loading the data into an array, updating the array, then dumping it back to the range will be faster.

    Also calling
    Please Login or Register  to view this content.
    at the top of your sub and
    Please Login or Register  to view this content.
    at the bottom will make it faster.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ 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] Problem with array types: variant vs. string array when appending data to a .csv
    By Rabk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-15-2022, 04:31 PM
  2. [SOLVED] A variable defined as variant or variant array
    By billj in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-14-2016, 05:35 PM
  3. [SOLVED] Type Mismatch, variant variable although numeric won't allow numeric manipulation
    By Rokn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-25-2016, 04:02 PM
  4. Replies: 1
    Last Post: 07-25-2016, 03:09 PM
  5. [SOLVED] Copy and paste from random order to alpha-numeric order
    By OthelloDog in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-03-2016, 11:11 PM
  6. Does setting a variant acting as an array equal to "" accomplish same as "Erase" variant?
    By dmasters4919 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2014, 05:59 PM
  7. Array problem: Key words-Variant Array, single-element, type mismatch error
    By davidm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-08-2005, 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