OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 441
- Office Version
- 2019
- Platform
- Windows
Thanks in advance for any assistance provided by anyone.
I am new to Arrays and Scripting Dictionaries.
I would like to read the following values into a Scripting Dictionary and then run some code based on that data. If that data does not exist in my data set, I want to perform an operation.
Read the following into a dictionary
If any of those values exists in my data set, where my data set is as follows
I do not want to perform say an operation as such (sample code):
I am new to Arrays and Scripting Dictionaries.
I would like to read the following values into a Scripting Dictionary and then run some code based on that data. If that data does not exist in my data set, I want to perform an operation.
Read the following into a dictionary
Stocks - Tool, Analysis - Get Data Macro Update - (Active).xlsm | |||
---|---|---|---|
A | |||
1 | Region | ||
2 | Region 1 | ||
3 | Region 2 | ||
4 | Region 4 | ||
5 | Region 6 | ||
6 | Region 7 | ||
Data |
If any of those values exists in my data set, where my data set is as follows
Stocks - Tool, Analysis - Get Data Macro Update - (Active).xlsm | |||
---|---|---|---|
A | |||
1 | Region | ||
2 | Region 1 | ||
3 | Region 2 | ||
4 | Region 3 | ||
5 | Region 4 | ||
6 | Region 5 | ||
7 | Region 6 | ||
8 | Region 7 | ||
SA |
I do not want to perform say an operation as such (sample code):
VBA Code:
Option Explicit
'***************************************************************************************************************
Sub MACRO_MXX_Script_Dic_Test()
'_______________________________________________________________________________________________________________
'Turn off alerts, screen updates, and automatic calculation
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlManual
'_______________________________________________________________________________________________________________
'Dimensioning
'Dim
Dim i As Long, j As Long
Dim aDictionary As Object
'_________________________________________________________________________________________________________________
'Code -
Set aDictionary = CreateObject("Scripting.Dictionary")
With Sheets("Data")
For j = 2 To 6
aDictionary(j, 1) = .Range(j, 1).Value
Next j
End With
With Sheets("SA")
For i = 2 To 8
'code - If (values does not exist in the Dictionary) then MsgBox .Range(i, 1)
Next j
End With
'_________________________________________________________________________________________________________________
'Turn on alerts and screen updates, and calculate
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Calculate
'_________________________________________________________________________________________________________________
'
End Sub