HELP PLEASE, with VBA Dictionary, totally stuck!!1

DavyJones90

Board Regular
Joined
Feb 23, 2022
Messages
62
Office Version
  1. 365
Platform
  1. Windows
Hey guys, thanks in advance.
I am trying to compare a value in a dictionary, but dictionary.exist will obviously not help me here. How do I do it? This is my code

VBA Code:
With sys
        For Each Cl In .Range("A5", .Range("A" & Rows.Count).End(xlUp))
            Dic(Cl.Value) = Cl.Offset(, 24).Value
        Next Cl
    End With
        With Sarrows
        For Each Cl In .Range("F6", .Range("F" & Rows.Count).End(xlUp))
        
            If Dic.exists(Cl.Value) Then Cl.Offset(25, 4).Value = Dic(Cl.Value) 'This works perfectly
            If Dic.exists(ChrW(&H2198)) Then Cl.Offset(26, 0).Value = "RANGE-Reverse All Arrows to " + ChrW(&H2191) 'This does nothing
            If Dic.exists(ChrW(&H2197)) Then Cl.Offset(26, 0).Value = "RANGE-Reverse All Arrows to " + ChrW(&H2193) ' this does nothing
            
        Next Cl
    End With

Thank you all
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
What do you have in you sys range (column A) ? Symbols or Values ?
And also in Column F
Please show us.
The code works in principle.
 
Last edited:
Upvote 0
sorry about that, does this help?

VBA Code:
Public Sub CurrencyAAM()
    
   
    Dim Cl As Range
    Dim Dic As Object
    Dim sys As Worksheet
    'Dim arrow As Worksheet
    Dim Sarrows As Worksheet
    
    

    Set sys = ThisWorkbook.Sheets("$Auto")
   ' Set arrow = Workbooks("CURRENCIES  W-D System.xlsm").Worksheets("Final ARROWS")
    Set Sarrows = ThisWorkbook.Sheets("$MW")
    Set Dic = CreateObject("scripting.dictionary")


sys has symbols, basically arrows, used to evaluate somehting, most look like this ↖↗
 
Upvote 0
That tells me what you are loading into the dictionary, what is in column F that you are using to retrieve the value.
 
Upvote 0
I may not get back online until tomorrow but this might be enough to show your dictionary code is working fine and that you have a data issue.
It prints the fact that is exists in the dictionary to the immediate window.

VBA Code:
Sub TestSymbolsInDict()

    Dim Dic As Object, DicKey As String
    Dim Cl As Range
    Dim sys As Worksheet, Sarrows As Worksheet
    
    Set sys = ActiveSheet
    Set Sarrows = ActiveSheet

    Set Dic = CreateObject("Scripting.dictionary")

    With sys
        For Each Cl In .Range("A5", .Range("A" & Rows.Count).End(xlUp))
            Dic(Cl.Value) = Cl.Offset(, 24).Value
        Next Cl
    End With
    
    If Dic.exists(ChrW(&H2198)) Then Debug.Print "H2198" & " exists"
    If Dic.exists(ChrW(&H2197)) Then Debug.Print "H2197" & " exists"

End Sub

20220910 VBA Sorting symbols in a dictionary DavyJones90.xlsm
A
1
2
3
4Source Symbols
5
6
7
8
Sample
 
Upvote 0
It seems to me, VBA isn't recognizing the hex code as the symbol, meaning, if I print the dictionary values, I get a line of questionmarks. Obviously because it doesnt habe those. But when I search directly with hex code it returns nothing. Any way to go about this?
 
Upvote 0
You are in a different time zone to me. If you don't show me your actual code and what you have in your spreadsheet, this is going to take days.
I assume your real code is looking up using column F as the lookup value. I previously asked you to show me to show me column F.
My code proves your sample lines work as far as the if statement using hex values goes.
Otherwise put a sample spreadsheet with your code on a share platform and provide the link here.
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,004
Members
452,374
Latest member
keccles

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