VBA: Remove all items from Scripting Dictionary

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,364
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
How to remove all from the scripting dictionary when running to separate extractions? I've read where you can use dict.removeall, but in this case, dict was not declared. Does it need to be declared somehow?

Code:
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]    With CreateObject("scripting.dictionary")[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]        For Each Cl In rng
            If Mid(Cl.Value, 4, 1) = "X" Then
                .Item(Cl.Value) = Empty
            End If
        Next Cl
        Sheet3.Range("AV8").Resize(.Count).Value = WorksheetFunction.Transpose(.keys)
        
        For Each Cl In rng
            If Left(Cl.Value, 1) = 0 Then
                .Item(Cl.Value) = Empty
            End If
        Next Cl
        Sheet3.Range("AZ8").Resize(.Count).Value = WorksheetFunction.Transpose(.keys)
    
    End With
[/FONT]
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Untested but why can't you use .RemoveAll within the dictionary's With..EndWith block (just like you did for the .Item property)?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,800
Messages
6,121,641
Members
449,044
Latest member
hherna01

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