Runtime error 451 on dictionary testing

yxz152830

Active Member
Joined
Oct 6, 2021
Messages
393
Office Version
  1. 365
Platform
  1. Windows
Gurus,
i was trying out dictionary to solve a problem and this error occurs. I checked out the microsoft doc but still confused. What is the problem with the debug.print here? both give me "

Runtime Code 451 Property let procedure not defined and property get procedure did not return an object"​

Checking local windows I can see dictionary starts taking in values.

VBA Code:
Sub asjdiajdij()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
For Each cell In Sheets("abc").ListObjects("abc").DataBodyRange.Columns(1).Cells
d(cell.Value & cell.Offset(0, 1).Value) = ""
Debug.Print d.items(1)
Debug.Print d.keys(1)
Next cell
End Sub
 

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).
As you are using late binding you need to use
VBA Code:
Debug.Print d.Items()(0)
Debug.Print d.Keys()(0)
although that will only give you the 1st key. To get all the keys
VBA Code:
Debug.Print d.Keys()(d.count - 1)
 
Upvote 0
Solution
As you are using late binding you need to use
VBA Code:
Debug.Print d.Items()(0)
Debug.Print d.Keys()(0)
although that will only give you the 1st key. To get all the keys
VBA Code:
Debug.Print d.Keys()(d.count - 1)
hi what is late binding and if I want to do early binding how do i rewrite the code? thanks!
 
Upvote 0
Last edited:
Upvote 0
I've no idea why it's needed, it just is.
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,054
Latest member
juliecooper255

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