+ Reply to Thread
Results 1 to 3 of 3

Edit data validation formula from vba

Hybrid View

zlackoff Edit data validation formula... 01-14-2010, 06:19 PM
rylo Re: Edit data validation... 01-14-2010, 07:32 PM
zlackoff Re: Edit data validation... 01-14-2010, 07:54 PM
  1. #1
    Registered User
    Join Date
    01-09-2010
    Location
    boston, ma
    MS-Off Ver
    Excel 2007
    Posts
    10

    Edit data validation formula from vba

    I have a cell that uses list type data validation. I need to be able to update the list of allowable values via a macro and would greatly prefer not using a range in excel. I've been able to create the string that I want as the formula but cannot change the formula. I'm not very familiar with this aspect of excel macros (data validation) so this is my best guess.

    tempStr = "=" & Range(cellWithValidation).Validation.Formula1 & ", " & valueToAdd
    Range(cellWithValidation).Validation.Formula1 = tempStr
    I'm not sure if i need the "=" at the beginning of tempStr but it doesn't work either way. Also, I checked to make sure tempStr is the full list and it's correct, the second line is where the error happens.

    The error is: Compile Error. Wrong number of arguments or invalid property assignment.

    A fix to my code or a better solution equally welcome. Thanks in advance.
    Last edited by zlackoff; 01-14-2010 at 07:54 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Edit data validation formula from vba

    Hi

    More like

    tempstr = Range(cellWithValidation).Validation.Formula1 & "," & valuetoadd
      Range(cellWithValidation).Validation.Delete
      
      Range(cellWithValidation).Validation.Add xlValidateList, , , tempstr
    rylo

  3. #3
    Registered User
    Join Date
    01-09-2010
    Location
    boston, ma
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Edit data validation formula from vba

    worked beautifully, thank you!

+ 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