+ Reply to Thread
Results 1 to 3 of 3

add new row to validation list using VBA

  1. #1
    Forum Contributor nasser's Avatar
    Join Date
    12-29-2006
    Location
    Kuwait
    MS-Off Ver
    2010-2013-2016
    Posts
    216

    add new row to validation list using VBA

    hello,
    I'm using Validation list in my sheet, and in case I've got a new item not in the list, the below code helping me to just type it and it will automatically added to the validation list,
    but i face 2 problems which is :
    First: I want the new item to be added in a new row, not just a new cell in the column.
    Second : I use 2 worksheets for validation lists which (List - Subs) and I want to effect only Subs to add a new row, "List" is working fine by adding a new cell only
    here is the code
    Please Login or Register  to view this content.
    thank you in advance

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

    Re: add new row to validation list using VBA

    Hey Nasser,

    The way to add a new value to a validation list is by using Dynamic Named Ranges. Read about them at:

    http://analyticsdemystified.com/exce...ns-done-right/
    http://www.myonlinetraininghub.com/e...ata-validation
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor nasser's Avatar
    Join Date
    12-29-2006
    Location
    Kuwait
    MS-Off Ver
    2010-2013-2016
    Posts
    216

    Re: add new row to validation list using VBA

    Looks I was asking the wrong question , here is my work space
    sheet1 "List"
    Place Color
    Alex. Black
    Cairo Blue
    Giza Green
    Haram Red
    Tiba Yellow

    Sheet2 "Subs"
    Acc.No. Contractor Name Code
    1 Frank 987
    2 George 876
    3 Fadi
    4 Nader
    5 Kimo 543
    6 Naser 432

    Name Ranges
    Acc.No.=OFFSET(Subs!$A$2,0,0,COUNTA(Subs!$A:$A),1)
    colors =OFFSET(List!$B$2,0,0,COUNTA(List!$B:$B),1)
    place=OFFSET(List!$A$2,0,0,COUNTA(List!$A:$A),1)

    Work Sheet
    Place Color Acc. No. Contractor Code
    Cairo Red 1 Frank 987
    Giza Yellow 5 Kimo 543
    #N/A #N/A
    #N/A #N/A
    #N/A #N/A
    #N/A #N/A
    #N/A #N/A

    Formula in Contractor Column (D2) = INDEX(Subs!B:B,MATCH(C2,Subs!A:A,0))
    Formula in Code Column (E2) = INDEX(Subs!C:C,MATCH(C2,Subs!A:A,0))

    Validation list in Column A = place
    Validation list in Column B = colors
    Validation list in Column C = Acc.No.
    First Question is that I want the code which I sent in the begining to work for both sheets (Subs - List)
    Second Question is that if the Acc.No. is not in the list Then I will add it manual and it should automatically added to the "Subs", and that means I should also manually add the Contractor and the code instead of the formula, and also should be in same row with the Acc.No.
    OR if the code is not already in the list like in the first sheet under (Fadi and Nader) so once I add it manually in the Work sheet, it should be added to the List

+ 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. Replies: 3
    Last Post: 05-09-2016, 08:27 PM
  2. Replies: 1
    Last Post: 11-05-2013, 12:40 AM
  3. Replies: 0
    Last Post: 01-09-2013, 11:44 AM
  4. [SOLVED] Reset dependant validation list when the previous validation list is changed.
    By Rimmu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-10-2012, 09:23 AM
  5. How to incorporate validation list in custom validation?
    By ohlalayeah in forum Excel General
    Replies: 11
    Last Post: 08-07-2012, 06:01 AM
  6. Replies: 3
    Last Post: 07-20-2012, 09:52 AM
  7. Replies: 1
    Last Post: 11-09-2007, 09:18 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