+ Reply to Thread
Results 1 to 13 of 13

Help with comparing Variant Array with itself

Hybrid View

  1. #1
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,454

    Re: Help with comparing Variant Array with itself

    I think you are using the join function incorrectly. It looks like you are using it like the CONCATENATE() function where you are expecting it to join two strings. According the help file (http://msdn.microsoft.com/en-us/libr...=vs.90%29.aspx ), the Join function takes a one dimensional array and joins each element of the array, divided by the assigned delimiter. In observing the "compare" variable in the Locals/Watch window, it appears that VBA is treating compare as a 2D array (even though one dimension is 1 to 1), and not accepting compare as an argument for the join function. I'm not exactly sure what you are doing with the join function (I don't see why you are trying to join the array into a single long text string). If you want to use the join function, you are going to need to do something different in assigning the array to compare.

    One observation. It seems like all this is doing is a relatively simple COUNTIF(). U2=1/COUNTIF($A$1:$A$300000,A1) (or whatever the reference is). Depending on where this task fits into the overall project, it might be easier to use a worksheet function rather than VBA.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  2. #2
    Registered User
    Join Date
    06-02-2014
    Posts
    11

    Re: Help with comparing Variant Array with itself

    Thanks for the reply!

    Yes, I am most likely using the join function incorrectly for that was not my intention. I know you cannot compare two elements of variant arrays using = , eg. compare(i) = compare(j) so I was trying to get around that.

    I did have code that used a countif function previous to this. However, it took WAY too long to run the macro. Rumor has it, using variants can cut down on the time, so I was trying to play around with those.

    Would you have any advice to get around the compare(i) = compare(j) dilema?

+ 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. Variant vs Array
    By Kyle123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-26-2012, 09:45 AM
  2. Array problem: Key words-Variant Array, single-element, type mismatch error
    By davidm in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-09-2005, 01:54 AM
  3. 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
  4. Moving a Variant to Array
    By Ivan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-07-2005, 08:05 AM
  5. [SOLVED] ReDim Object array as parameter of Variant array
    By Peter T in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-10-2005, 10:06 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