+ Reply to Thread
Results 1 to 6 of 6

Change Data Validation List with VBA

  1. #1
    Registered User
    Join Date
    07-12-2012
    Location
    New Hampshire, United States
    MS-Off Ver
    Excel 2010
    Posts
    80

    Change Data Validation List with VBA

    Here is my current code:

    Please Login or Register  to view this content.
    The end of the code is where I am having the issue. It is supposed to change the data validation list of some cells. It is assigned to a button and when the button is clicked and error occurs and when I click debug it highlights
    Please Login or Register  to view this content.
    Any help would be greatly appreciated.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Change Data Validation List with VBA

    Hi carrob,

    Without looking too hard at your code here is my guess.
    It has to do with scope (not the mouthwash). The idea is that you have your code behind a single sheet (based on the _Click) or behind a userform. When the code is in a subdivision of a userform or single sheet, it doesn't know about other sheets or userforms. The answer to these problems is to move the code to a MODULE that then can see all the other objects and run the code from there.
    See http://www.cpearson.com/Excel/Scope.aspx
    If this is not the problem - attach a workbook and we can look further.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    07-12-2012
    Location
    New Hampshire, United States
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Change Data Validation List with VBA

    Thanks for responding MarvinP. The code I posted is already in my Module1. I tried attaching my workbook but an error occured and I'm not sure what the problem is...is there a size limit? my workbook is 1.44 MB.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Change Data Validation List with VBA

    Yep - there is a size limit on posted attachements.

  5. #5
    Registered User
    Join Date
    07-12-2012
    Location
    New Hampshire, United States
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Change Data Validation List with VBA

    I created a zip file to get it under 1 MB but that also did not work, are zip files also not allowed?

  6. #6
    Registered User
    Join Date
    07-12-2012
    Location
    New Hampshire, United States
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Change Data Validation List with VBA

    I fixed it by changing xlvalidatecustom to xlvalidatelist. Custom is used when the list is defined in the VBA, whereas list is used when the list is in a worksheet.

+ 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