Script Dictionary - Item

billandrew

Well-known Member
Joined
Mar 9, 2014
Messages
743
I have the below code which adds the desired sheets from Column A. My question is the understanding on the "Nothing".

My attempt to interpret is this is related to an item reference, in this case not necessary therefore the "Nothing"

Thank You for any explanation.....



Code:
[TABLE="width: 70"]
 <colgroup><col width="70" style="width:53pt"> </colgroup><tbody>[TR]
  [TD="width: 70"]Sub AddSheets()[/TD]
 [/TR]
 [TR]
  [TD]    Dim c As Range[/TD]
 [/TR]
 [TR]
  [TD]    With CreateObject("Scripting.dictionary")[/TD]
 [/TR]
 [TR]
  [TD]        For Each c In Range("A2", Range("A" & Rows.Count).End(xlUp))[/TD]
 [/TR]
 [TR]
  [TD]        If Not .exists(c.Value) Then Sheets.Add(, Sheets(1)).Name = c.Value[/TD]
 [/TR]
 [TR]
  [TD]        .Add c.Value, [COLOR=#ff0000]Nothing[/COLOR][/TD]
 [/TR]
 [TR]
  [TD]        Next c[/TD]
 [/TR]
 [TR]
  [TD]        End With[/TD]
 [/TR]
 [TR]
  [TD]    End Sub[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
When adding to a dictionary you add a key and a value.

In this case you don't really need a value but it's not an optional argument.
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,965
Messages
6,127,969
Members
449,414
Latest member
sameri

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