Looping a macro through a dictionary.

Hawk11ns

Board Regular
Joined
Jul 21, 2015
Messages
61
Office Version
  1. 365
Platform
  1. Windows
I have 12 projects and 3 variables per project (INT, STR, STR).

VBA Code:
'Lists
'rec = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
'prj = ["ALD", "AZ1", "FL1", "FL4", "FL5", "GA3", "GA4", "MA1", "MS3", "MW1", "MW2", "TN1"]
'Map = ["B2", "B4", "B6", "B8", "B10", "B12", "B14", "B16", "B18", "B20", "B20", "B22"]

'data = {[1, 'ALD', 'B2'], [2, 'AZ1', 'B4'], [3, 'FL1', 'B6'], [4, 'FL4', 'B8'], [5, 'FL5', 'B10'], [6, 'GA3', 'B12'], [7, 'GA4', 'B14'], [8, 'MA1', 'B16'], [9, 'MS3', 'B18'], [10, 'MW1', 'B20'], [11, 'MW2', 'B20'], [12, 'TN1', 'B22']}

I want to loop these variables, together at the project-level, across the macro. For example:

for key, value in data.items():
record = d[key]
project = d[items(0)]
map = d[items(1)]

How can I properly translate this to VBA? Thanks in advance!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,214,819
Messages
6,121,729
Members
449,049
Latest member
MiguekHeka

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