VBA multi value Dictionary

challen908

New Member
Joined
Jan 11, 2022
Messages
5
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. MacOS
I am trying to build a multi value dictionary from a sheet of data that has 4 different columns of data, where the first column would be the key and the 3 next columns would be the items

I keep getting a compile error: Method or Data member not found. Please help

1641934901649.png
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Can you post the code, not an image of the code?

Also, include the code for the class ClsFlight.
 
Upvote 0
VBA Code:
Public FlightNum As String
Public EDUNum As String
Public VCPN As String
Public Status As String

Sub Main()

    Dim Dic As Dictionary

    Set Dic = ReadMultiItems

    'WriteToActiveCell Dic

End Sub

Private Function ReadMultiItems() As Dictionary

    Dim Dic As New Dictionary

    Dim sh As Worksheet
    Set sh = ThisWorkbook.Sheets("EDUData")

    Dim rg As Range
    Set rg = sh.Range("A1").CurrentRegion

    Dim oFlight As ClsFlight, i As Long
    Dim FlightNum As String

    For i = 2 To rg.Rows.Count
        FlightNum = rg.Cells(i, 1).Value

        If Dic.Exists(FlightNum) = True Then
            Set oFlight = Dic(FlightNum)
        Else
            Set oFlight = New ClsFlight
            Dic.Add FlightNum, oFlight
        End If

        oFlight.FlightNum = FlightNum
        oFlight.EDUNum = oFlight.EDUNum + rg.Cells(i, 2).Value
        oFlight.VCPN = oFlight.VCPN + rg.Cells(i, 3).Value
        oFlight.Status = oFlight.Status + rg.Cells(i, 4).Value

    Next i
    Set ReadMultiItems = Dic
End Function
 
Upvote 0
I figured it out I think. I didn't add the Public string decorations to the Class Module
 
Upvote 0
Solution

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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