Solved

remove used item(s) from validation list

Posted on 2011-02-17
11
351 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vlookup for in-between dates 4 39
Excel IF formula 3 21
Manipulate Range in Excel VBA 6 24
Msgbox tickler 11 26
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

810 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