+ Reply to Thread
Results 1 to 3 of 3

Adding items to Dictionary object

  1. #1
    Registered User
    Join Date
    08-30-2005
    Posts
    67

    Adding items to Dictionary object

    Hi,

    I am creating a Scripting Dictionary where items are added based on a certain criteria. The item value is not just a specific cell value but it's a combination of cell value and a vlookup. So it looks like this:

    Please Login or Register  to view this content.
    This basically results in something like: "Code: 012345 SMITH"

    If VLookup returns an error, meaning that a specific code has no name assigned to it, I want items to continue adding to the dictionary but wihtout name. So I have added On Error line to handle that. This is how it currently looks:

    Please Login or Register  to view this content.
    My issue here is that it does not want to associate a new key to the error case. So it tells me that a key is already associated with an element of this collection and breaks. Is it at all possible to have diferent types of items added to the the same Dictionary? How do I do that?

    Thanks in advance for any suggestion.

    Eduard

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Adding items to Dictionary object

    One option:
    Pass the vlookup into a string variable. Test that for error and add relevant version to dictionary.
    I try to avoid using error handling as an expected operation (I think there's a programming principle around this, but don't know).
    CC


    If you feel really indebted please consider a donation to charity. My preferred charity is ActionAid but there are plenty of worthy alternatives.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    Eduard

    Try checking the result of the vlookup with IsError.

    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1