+ Reply to Thread
Results 1 to 5 of 5

Select next/previous item from data validation list using Command Button

Hybrid View

msn.niyasu Select next/previous item... 03-04-2014, 10:04 AM
nathansav Re: Select next/previous item... 03-04-2014, 11:07 AM
msn.niyasu Re: Select next/previous item... 03-05-2014, 02:43 AM
msn.niyasu Re: Select next/previous item... 03-09-2014, 01:20 AM
msn.niyasu Re: Select next/previous item... 03-09-2014, 07:26 AM
  1. #1
    Registered User
    Join Date
    03-04-2014
    Location
    Dubai
    MS-Off Ver
    Excel 2003
    Posts
    12

    Select next/previous item from data validation list using Command Button

    I have a data validation list in cell "A1", the validation list is sourced from items which are listed under column "AA". And i also have two command buttons to display the next/previous item from the list while clicking the respective buttons (the same should display in cell A1)

    The incell dropdown button working very well to select the desired item. But if i use the command buttons to change the item from the list, from the next time the sheet get activated I am getting the following error message

    “Run-time error ' -2147417848(80010108) Method 'add' of object 'validation' failed”

    i also wanted the first item from the list to be displayed each time the sheet get activated

    The file is attached for reference,

    Please help
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Select next/previous item from data validation list using Command Button

    I'd use something like

    range("a1").value =worksheetfunction.Index(range(Range("a1").Validation.Formula1),WorksheetFunction.Match(Range("a1").value,range(Range("a1").Validation.Formula1),false)+1,1)

    for next

    and

    range("a1").value =worksheetfunction.Index(range(Range("a1").Validation.Formula1),WorksheetFunction.Match(Range("a1").value,range(Range("a1").Validation.Formula1),false)-1,1)

    for prev

    with range A1 being the cell with the dropdown validation. You'll need to add a check to make sure the result is never 0 or more rows than in the list.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    03-04-2014
    Location
    Dubai
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Select next/previous item from data validation list using Command Button

    Dear nathansav:
    Thank you for your suggestion;

    I have removed all the previous codes for "NEXT" and "PREVIOUS" command buttons and replace with your codes; but that just helped me to reduce the length of cording. Still I am facing the same error message, when I go from and come back to the sheet1.

    find the attached file for reference
    Attached Files Attached Files
    Last edited by msn.niyasu; 03-05-2014 at 02:47 AM.

  4. #4
    Registered User
    Join Date
    03-04-2014
    Location
    Dubai
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Select next/previous item from data validation list using Command Button

    Can anyone help me on this, I just want the data validation list to be updated each time the sheet get activated (sheet1- A1), and I want to use command buttons to select next/previous item from the list. But the problem that I am facing is that, whenever I use the command buttons to select items from the data validation list an error occurring the next time when the sheet get activated.

    Please find the file attached in my previous reply

  5. #5
    Registered User
    Join Date
    03-04-2014
    Location
    Dubai
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Select next/previous item from data validation list using Command Button

    please help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Select item of a dropdown list (data validation) and refreshes values of all pivot tables
    By siroco79 in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 03-06-2014, 05:35 AM
  2. macro to select each item in data validation list
    By Olivia Wong in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-30-2013, 01:59 PM
  3. Macro to select an item from a data validation list
    By blindedbythepj in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-12-2012, 03:53 PM
  4. Replies: 1
    Last Post: 06-11-2012, 04:43 AM
  5. Macro to select an item in a Validation List
    By emwhite in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-16-2010, 10:41 AM

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