Odd behaviour from Arrays - can't find matches

TheRedCardinal

Board Regular
Joined
Jul 11, 2019
Messages
243
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: 5
  • 1686582151012.png
    1686582151012.png
    2.6 KB · Views: 4
  • 1686582185306.png
    1686582185306.png
    3.9 KB · Views: 5
  • 1686582236925.png
    1686582236925.png
    5 KB · Views: 7
Last edited:
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,215,069
Messages
6,122,951
Members
449,095
Latest member
nmaske

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