Dictionary and run time error 424

chuckjitsu

New Member
Joined
Apr 24, 2015
Messages
40
Office Version
  1. 365
  2. 2016
I created a Dictionary via late binding and along with the key value, it contains seven other columns/sets of values that I added via a class module. That part worked fine and I was able to add the values I wanted. A sample of the output is below. The values in V1-V7 columns are other key values in the dictionary. What I'm attempting to do via the code snippet below is assign the value associated with V1 to a variable, check and see if that key exists, and delete it if it does. So using the first row as an example, I would be assigning the V1 value of J1:J5 to a variable, checking to see if that key exists in the dictionary and deleting it if it does.

I thought that would be straightforward, but I was clearly wrong as I keep getting a 424 run time error with the line vremove1 = dict5(key).V1 being the problem as it is highlighted on the debugger. Thanks in advance for the help as I've struggled with this. For brevity sake I left out the other part of the code (Dim statements, dictionary creation, etc.) and just included the part that fails, as seen below.

KEYV1V2V3V4V5V6V7
A1:E1J1:J5F10:J10A6:A10A1:A5A10:E10J6:J10F1:J1
B1:F1J2:J6E10:I10A5:A9A2:A6B10:F10J5:J9E1:I1
C1:G1J3:J7D10:H10A4:A8A3:A7C10:G10J4:J8D1:H1
D1:H1J4:J8C10:G10A3:A7A4:A8D10:H10J3:J7C1:G1
E1:I1J5:J9B10:F10A2:A6A5:A9E10:I10J2:J6B1:F1
F1:J1J6:J10A10:E10A1:A5A6:A10F10:J10J1:J5A1:E1

VBA Code:
For Each key In dict5.Keys
vremove1 = dict5(key).V1
If dict5.Exists(vremove1) Then
dict5.Remove vremove1
End If
Next key
Exit Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

bebo021999

Well-known Member
Joined
Jul 14, 2011
Messages
1,799
Office Version
  1. 2016
For Each key In dict5.Keys ' loop through key value of dict5
vremove1 = dict5(key).V1 ==>
should be:
vremove1 = key
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
77,703
Office Version
  1. 365
Platform
  1. Windows
For brevity sake I left out the other part of the code (Dim statements, dictionary creation, etc.) and just included the part that fails, as seen below.
Please do not do that. We have know way of knowing what V1 is, how it's declared, or how it's populated.
 

chuckjitsu

New Member
Joined
Apr 24, 2015
Messages
40
Office Version
  1. 365
  2. 2016
For Each key In dict5.Keys ' loop through key value of dict5
vremove1 = dict5(key).V1 ==>
should be:
vremove1 = key
Hi bebo. Thank you for the response. Using my example above, it seems like your code would be removing the key value A1:E1 and I'm trying to remove the key value associated with V1, or J1:J5, but it's entirely possible I'm misunderstanding.
 

Forum statistics

Threads
1,176,089
Messages
5,901,339
Members
434,886
Latest member
qazibelal

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
Top