Validation List - VB Reference

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MAdcock
    New Member
    • Nov 2006
    • 13

    #1

    Validation List - VB Reference

    Hi,

    I am struggling with most probably a straight forward problem, but here goes. I want to write some VB coding to match cell values to a list I have already made "Stock" so that only rows with the values as defined in my list remain. My problem is being able to reference the list "Stock" in VB - is it possible to do so rather than retyping the list seperated by commas?

    Please could someone help me! Many thanks

    Mark
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by MAdcock
    I am struggling with most probably a straight forward problem, but here goes. I want to write some VB coding to match cell values to a list I have already made "Stock" so that only rows with the values as defined in my list remain. My problem is being able to reference the list "Stock" in VB - is it possible to do so rather than retyping the list seperated by commas?
    Is this in Excel?

    Comment

    • MAdcock
      New Member
      • Nov 2006
      • 13

      #3
      Yes, sorry I forgot to mention it is for an excel spreadsheet.

      Help is much appreciated!

      Comment

      • MAdcock
        New Member
        • Nov 2006
        • 13

        #4
        Excel list defined via:

        Insert - Name - Define

        Just to make sure :)

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by MAdcock
          Excel list defined via:

          Insert - Name - Define

          Just to make sure :)
          Sorry, I haven't found time to look into this one (and nobody else seems to be hopping onboard, which is a little surprising. However, one tip I often give people trying to write macro code in Excel is this. Start recording a new macro, do the function yourself (if possible), then stop recording. You can then edit the macro, and the code has been written for you.

          This will not necessarily produce exactly what you need, because for one thing, it's often specific to the particular location at which (or the data on which) you ran it. But it is a great way to get started and learn a lot about how to code things.

          Comment

          • MAdcock
            New Member
            • Nov 2006
            • 13

            #6
            Thanks for that, I do that already and yes the problem is that the macro then references the cells rather than the "LIST" I am after.

            If anyone knows the answer - PLEASE PLEASE HELP

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              Originally posted by MAdcock
              Thanks for that, I do that already and yes the problem is that the macro then references the cells rather than the "LIST" I am after.

              If anyone knows the answer - PLEASE PLEASE HELP
              Hm... I'm not that familiar with lists in Excel. I played around and can get my code to refer to a range of cells by the name assigned to it, if that's any help.
              Code:
              Range("AABBCC").BorderAround xlContinuous, xlMedium
              The online help mentions that the .Names property can be used to find the names available, too.

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                Here are a couple of links I found which may provide some sort of info. It's hard to tell whether they will help or not, because a lot of the stuff I searched refers to "lists" in the general sense, basically meaning any bunch of cells, rtaher than what Excel specifically refers to as a list. Anyway, here they are...

                Comment

                Working...