Solved

remove used item(s) from validation list

Posted on 2011-02-17
11
354 Views
Last Modified: 2012-05-11
I am trying to apply a validation list (inevitably from another sheet!) but as I go down the column I need the list to contract and discount the items which I have just used higher up the column. Excel Hacks (O'Reilly) - a book I rate - has some code for this but it does nothing - the validation is applied by =NamedRange but it does not seem to contract. I can post the code from the O'Reilly website if that would help. Intriguingly the debug routing does nothing either - not an hint of yellow
0
Comment
Question by:Pitfour
  • 6
  • 3
  • 2
11 Comments
 
LVL 45

Expert Comment

by:patrickab
ID: 34921906
Pitfour,

Please upload your file so that we can work with data that is significant for you.

Patrick
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34921973
Hello,

this can be done without any VBA. Debrah Dalgliesh has a tutorial on the contextures.com site: http://www.contextures.com/xlDataVal03.html

I've used this successfully in many situations. Not a line of VBA required. If you need help setting this up, please post a sample workbook.

cheers, teylyn
0
 

Author Comment

by:Pitfour
ID: 34922318
Teylyn and Patrickab

I have tried the contextures proposal  - no dice. I have attached a piece of data. I would rather do it in code - the ssheet needs to be used by ...others.
ValidList-trial.xls
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34922382
Hello,

see attached the formula version in place.

cheers, teylyn
Copy-of-ValidList-trial.xls
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34922389
By the way, you can hide Sheet1 and/or protect it against accidental changes from  "...others" by protecting it with a password after it has been set up.

cheers,
0
 

Author Comment

by:Pitfour
ID: 34922564
Works really well but briefly: pse can you outline the changes to be made when I add another 10 names to the list and the avail codes are 600 or so.

Thanks
0
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst earned 250 total points
ID: 34922639
Hello,

see attached file set up for 600 rows of codes in Sheet1 and up to 500 rows of data in Sheet2

The amended formulas are in Sheet1:

B1 =IF(COUNTIF(Sheet2!$B$1:$B$500,A1)>=1,"",ROW())  -- no change to previous version
C1 =IF(ROW(A1)-ROW(A$1)+1>COUNT(B$1:B$600),"",INDEX(A:A,SMALL(B$1:B$600,1+ROW(A1)-ROW(A$1))))  -- changed $B$13 to $B$600 in two places

Named range "NetList" refers to

=OFFSET(Sheet1!$C$1,0,0,COUNTA(Sheet1!$C$1:$C$600)-COUNTBLANK(Sheet1!$C$1:$C$600),1)  -- changed $C$13 to $C$600 in two places

If your list of codes gets longer than 600, you just need to set the C1 formula (remember to copy down!!) and the named range and adjust 600 to exactly the number of codes you have.

cheers, teylyn
Copy-of-ValidList-trial.xls
0
 

Author Comment

by:Pitfour
ID: 34924023
Ah, this works absolutely as intended, thank you. I am still perplexed by the OFFSET but it definitely ...works!!

Thanks for all your help

Robin, London
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34924175
Thanks. The Offset() looks daunting because of the nested CountA() and CountBlank(). Pluck it apart and it becomes easier

Offset syntax:

Offset(startRange, rows, columns, height, width)

=COUNTA(C1:C600) returns 600
=COUNTBLANK(C1:C600) returns the number of blank cells in the range, let's say 5

so

Offset(C1, 0 rows, 0 columns, 600-5 rows high, 1 column wide)

Thinking about this, you could also use the count of numbers in column B with Count(). This would not count the cells with no number and the Offset() will look a little shorter:

=OFFSET(Sheet1!$C$1,0,0,COUNT(Sheet1!$B$1:$B$600),1)

cheers, teylyn

0
 
LVL 45

Expert Comment

by:patrickab
ID: 34924446
Pitfour,

If you can accept blanks in the Data Validation list then the formula for the cells in the named range can be much simpler:

=IF((COUNTIF($A$1:$A$7,A1)+COUNTIF(Sheet1!$A$1:$A$10,Sheet2!A1))>1,"",Sheet2!A1)

and copied down to the end of the data. It's in the attached file.

Patrick
DV-reducing-list-01.xls
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34925218
Be aware that blanks in a data validation list mean that ANY value can be entered into the cell. If you simply type a value, it will be accepted if the validation list contains blanks.

Cheers, teylyn
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question