+ Reply to Thread
Results 1 to 8 of 8

Variants look the same but report being different -- how are they different?

  1. #1
    Registered User
    Join Date
    05-13-2011
    Location
    Bellevue, WA, USA
    MS-Off Ver
    2019
    Posts
    45

    Variants look the same but report being different -- how are they different?

    I'm comparing many extremely large sheets -- several million cells in the used range (sheet.UsedRange), and many of them over 100MB -- and reporting any differences found. Often only a few differences are found among the several millions cells.

    To make the comparison faster, for each sheet being compared I'm setting the used range to a variant, turning the variant into a variant array:
    Dim myVariantArrayA as Variant 'do NOT declare as array.
    myVariantArrayA = mysheet.UsedRange

    But sometimes it reports two cells -- each a Variant in one of the two Variant arrays -- as being different (VariantA = VariantB returns False) when I don't see any difference:
    -- They are the same string (same characters).
    -- They have the same number of characters (len).
    -- Each character has the same Asc values and the same AscW values as the correstponding character in the other string.
    -- They have the same Typename and the same VarType.

    When I go back to the source cells on the sheets from which the Variants in the array were made, the two cells also report as being different from each other (cellA.Value = cellB.Value returns False) and I find all of the above plus:
    -- They have the same number formatting.

    If I press F2+Enter on the cells, the cells report as being the same as each other (cellA.Value = cellB.Value returns True).

    Using SendKeys to send F2 + Enter isn't a practical solution because the user will be running a report in the background that does comparisons like that on many sets of extremely large sheets, while the user does other work in the foreground.


    So is there any other way to detect the fact that they are the same without doing the F2+Enter?

    I'm especially interested in what is different in the Variants. In one example I'm looking at, they report a VarType of 5, indicating Double, and their Typename is also Double. So I don't think there is an object hiding in the Variant with some mysterious complexity. What is the difference, really, between those two Variants? And, is it possible to detect the difference in code?


    Thanks,

    Greg
    Last edited by GJL65; 11-07-2012 at 05:29 PM.

  2. #2
    Registered User
    Join Date
    10-24-2012
    Location
    Budapest
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Variants look the same but report being different -- how are they different?

    Hi!

    You only have to compare values or there are some other things?
    How are these cells filled? Manually/different macros, etc.

  3. #3
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Variants look the same but report being different -- how are they different?

    Where is the data coming from? Is it being imported?
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  4. #4
    Registered User
    Join Date
    05-13-2011
    Location
    Bellevue, WA, USA
    MS-Off Ver
    2019
    Posts
    45

    Re: Variants look the same but report being different -- how are they different?

    Hi yvorL,

    You only have to compare values or there are some other things?
    I'm only comparing values, but if the mystery difference is a result of a difference in the source, then I may need to report that there may be a difference there.


    How are these cells filled? Manually/different macros, etc.
    They are exported from a database called Apptio. I export tables from the Dev and Stage environments that should be identical, and report any differences found. Differences are often found.


    Thanks,

    Greg

  5. #5
    Registered User
    Join Date
    05-13-2011
    Location
    Bellevue, WA, USA
    MS-Off Ver
    2019
    Posts
    45

    Re: Variants look the same but report being different -- how are they different?

    Hi JapanDave,

    Where is the data coming from? Is it being imported?
    They are exported from a database called Apptio.


    Thanks,

    Greg

  6. #6
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Variants look the same but report being different -- how are they different?

    If that is the case then they are most likely different in some way. IME you will have to clean the data first, then compare it. Can you post a sample workbook with the actual data?

  7. #7
    Registered User
    Join Date
    10-24-2012
    Location
    Budapest
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Variants look the same but report being different -- how are they different?

    If that is the case then they are most likely different in some way.
    I agree.
    Try Trim, or something like that to get rid of any possible difference.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Variants look the same but report being different -- how are they different?

    What sort of data is it?

    Is it all text?

    How exactly are you comparing the data?
    If posting code please use code tags, see here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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