Odd behaviour from Arrays - can't find matches

TheRedCardinal

Active Member
Joined
Jul 11, 2019
Messages
250
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
My code does the following:

  • Loads in a range from a worksheet into an array
  • Loads in a range from another worksheet into a separate array
  • Loops through the first array in a specific column
  • Searches a column in the second array and counts how many times it appears
The code looks like this:

VBA Code:
        For Counter2 = 1 To UBound(IStat, 1)
        
            If FinalArray(Counter, a) = IStat(Counter2, b) Then Counter3 = Counter3 + 1
        
        Next Counter2

The variables a and b are used to identify the "columns" of the array and work ok.

The problem: I never get a value for Counter3 except 0.

Hovering over each expression in Step Through mode tells me that all parameters are working correctly, except that the search term in final array looks like a number (e.g. 9200) but in the search array, it is the same number inside quotation marks, so "9200". In fact, every line (including empties) in the search array is enclosed in "".

This is not returning a match.

I have tried:
  • Formatting the whole source data for both arrays as text
  • Formatting the specific columns as numbers

But so far to no avail.

Can anybody see a way around this?
 
Check the following points:

1. I can't test your macro, you are not putting all the information of all your sheets.
1686582119413.png

2. Also deleted.

3. Your macro has other problems
.
Missing some variables to declare.​

4. deleted this point.


5. I could go through the whole macro
, explain what the goal is and what the output is that you need.
Provides the information that is missing from the other sheets.​

--------------
I hope to hear from you soon.
Respectfully
Dante Amor
--------------​
 

Attachments

  • 1686582090817.png
    1686582090817.png
    15.5 KB · Views: 7
  • 1686582151012.png
    1686582151012.png
    2.6 KB · Views: 6
  • 1686582185306.png
    1686582185306.png
    3.9 KB · Views: 7
  • 1686582236925.png
    1686582236925.png
    5 KB · Views: 9
Last edited:
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top