Solved

remove used item(s) from validation list

Posted on 2011-02-17
11
349 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:teylyn
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
 
LVL 50

Expert Comment

by:teylyn
ID: 34922382
Hello,

see attached the formula version in place.

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

Expert Comment

by:teylyn
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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:
teylyn 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:teylyn
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:teylyn
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
My experience with Windows 10 over a one year period and suggestions for smooth operation
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

929 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now