+ Reply to Thread
Results 1 to 3 of 3

AddIn to create named range

  1. #1
    Registered User
    Join Date
    08-01-2009
    Location
    KC, USA
    MS-Off Ver
    Excel 2003
    Posts
    1

    Post AddIn to create named range

    I currently have many spreadsheets that use the same data validation lists. I would like to create an AddIn that would store the named arrays so they do not have to be placed in every separate workbook.

    This is my attempt so far...

    'Code contained in AddIn, showing just 1 of many data validation lists

    Dim PickName(3) As Variant
    PickName(0) = "Tom"
    PickName(1) = "Jack"
    PickName(2) = "Harry"
    PickName(3) = "Joe"

    'And then later in AddIn code called from a worksheet_change

    Select Case Range("A1").Value
    Case "Name"
    With Cell.Offset(0, 1).Validation
    .Add Type:=xlValidateList, _
    AlertStyle:=xlValidAlertStop, _
    Operator:= xlBetween, _
    Formula1:="=PickName"
    .IgnoreBlank = True
    .InCellDropdown = True
    End With
    .....

    Error 1004 highlights the .Add statement. I assume I am defining the array incorrectly. Or my methods are invalid.

    Thanks

  2. #2
    Registered User
    Join Date
    07-29-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: AddIn to create named range

    Can you attach the spreadsheet you're working with?

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: AddIn to create named range

    If you want a dropdown, then you have to use a range or a delimited string as far as I know. You can't use a function, unfortunately.
    Everyone who confuses correlation and causation ends up dead.

+ 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