Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 362
  • Last Modified:

remove used item(s) from validation list

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
Pitfour
Asked:
Pitfour
  • 6
  • 3
  • 2
1 Solution
 
patrickabCommented:
Pitfour,

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

Patrick
0
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
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
 
PitfourAuthor Commented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Hello,

see attached the formula version in place.

cheers, teylyn
Copy-of-ValidList-trial.xls
0
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
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
 
PitfourAuthor Commented:
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
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
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
 
PitfourAuthor Commented:
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
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
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
 
patrickabCommented:
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
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 6
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now