Rule for Dropdown > If the selected user already posted the value to database, then do not show in dropdown

The Godfather

New Member
Joined
Jul 22, 2011
Messages
30
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi,

I am a total beginner in VBA. I have an excel with two sheets as "form" and "database" (actually more but others are not relevant).

In the Form;
1) Users type their username, password, and select the week.
2) In the orange part, users type other stuff (to all 3 rows).
3) When submitted, all are transferred into database.
exc1.png

In the Database (the whole sheet is actually a table); usernames (Form sheet Cell "F5") are stored in C Column, week (Form sheet Cell "F7") is stored in D Column, and the other orange stuff is stored in other columns.
exc2.PNG

I need the dropdown list (Form sheet cell "F7") only to show the weeks which are not previously posted into database by the same user (which is typed into Form sheet cell "F5"), to prevent users posting other data using the same week. (For instance, user2 should not post anything again for Week 12, since he already posted as seen in database screenshot).

Could you please help me on how to do it? (Preferrably in VBA instead of data validation).

Thanks for reading.
 
Last edited:

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Try this, bit messy but the Filter Function does not work in Data Validation

Book1
ABCDEFGHIJKLMNO
1Record No Sub Record NoWeekOther DataOther DataOther DataOther Data
21user1Week 12irrelevantirrelevantirrelevantirrelevantUserWeek 1 Week 1
31user2Week 12irrelevantirrelevantirrelevantirrelevantuser1Week 2 Week 2
41user3Week 12irrelevantirrelevantirrelevantirrelevantWeek No.Week 3 Week 3
52user2Week 12irrelevantirrelevantirrelevantirrelevantWeek 4 Week 4
62user2Week 12irrelevantirrelevantirrelevantirrelevantWeek 5 Week 5
72user2Week 12irrelevantirrelevantirrelevantirrelevantWeek 6 Week 6
83user1Week 13irrelevantirrelevantirrelevantirrelevantWeek 7 Week 7
93user1Week 13irrelevantirrelevantirrelevantirrelevantWeek 8 Week 8
103user1Week 13irrelevantirrelevantirrelevantirrelevantWeek 9 Week 9
11Week 10 Week 10
12Week 11 Week 11
13Week 12user1Week 14
14Week 13user1Week 15
15Week 14 Week 16
16Week 15 Week 17
17Week 16 Week 18
18Week 17 Week 19
19Week 18 Week 20
20Week 19 Week 21
21Week 20 Week 22
22Week 21 Week 23
23Week 22 Week 24
24Week 23 Week 25
25Week 24 Week 26
26Week 25 Week 27
27Week 26 Week 28
28Week 27 Week 29
29Week 28 Week 30
30Week 29 Week 31
31Week 30 Week 32
32Week 31 Week 33
33Week 32 Week 34
34Week 33 Week 35
35Week 34 Week 36
36Week 35 Week 37
37Week 36 Week 38
38Week 37 Week 39
39Week 38 Week 40
40Week 39 Week 41
41Week 40 Week 42
42Week 41 Week 43
43Week 42 Week 44
44Week 43 Week 45
45Week 44 Week 46
46Week 45 Week 47
47Week 46 Week 48
48Week 47 Week 49
49Week 48 Week 50
50Week 49 Week 51
51Week 50 Week 52
52Week 51 
53Week 52 
Sheet1
Cell Formulas
RangeFormula
O2:O51O2=FILTER($M$2:$M$53,$N$2:$N$53<>$J$3,"")
N2:N53N2=IFERROR(INDEX($B$2:$B$10,MATCH($J$3&M2,$B$2:$B$10&$C$2:$C$10,0)),"")
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
J5List=$O$2#
 
Upvote 0
Can you create a filtered list and name, and then reference that filtered list?
Like this:
I had an error, reposting
 
Upvote 0
Okay, here is a mini workbook where a subset of a list is excluded from the data validation drop down.
This will require re-sizing of the data validation list from time to time. Additionally, this does not include the process to add the selected name and week to the database list It just builds the data validation list.

Book2
ABCDEFGH
1Week SelectionUserFilteredWeekSelectionUserAlready
2Week01JohnWeek01Week04
3Week02Week02Week05The Database Data
4Week03User Chose:Week03Week08UserNameWeekChosen
5Week04Week03Week06Week18JaneWeek01
6Week05Week07Week21JohnWeek04
7Week06Week09JohnWeek05
8Week07Week10SallyWeek06
9Week08Week11JohnWeek08
10Week09Week12SallyWeek08
11Week10Week13SallyWeek09
12Week11Week14JaneWeek13
13Week12Week15JaneWeek14
14Week13Week16SallyWeek14
15Week14Week17JaneWeek17
16Week15Week19SallyWeek17
17Week16Week20JaneWeek18
18Week17Week22JohnWeek18
19Week18JohnWeek21
20Week19
21Week20
22Week21
23Week22
24
Sheet1
Cell Formulas
RangeFormula
D2:D18D2=FILTER($A$2:$A$23,MMULT(--(TRANSPOSE(F2#)=A2:A23),SEQUENCE(ROWS(F2#),1,1,0))=0)
F2:F6F2=SORT(FILTER($H$5:$H$19,$G$5:$G$19=B2),1,1)
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
B5List=FilteredWeekSelection
 
Upvote 0
Thank you Skybluekid and awoohaw. I tried to implement both solutions, I believe awoohaw's solution also fits more to my needs.
However when I type =filter, or =sort Excel responds "the function is not valid".

Is it possible to solve it with some kind of index.match?
As in; there is already a weeklist defined somewere in my worksheet (as both of you suggested in your solutions); from Week 1 to Week 12.
When user opens dropdown, the dropdown will look at tle weeklist first, then look database and if the username & week matches in data, only show remaining weeks for that user.

Thanks.
 
Upvote 0
are you doing this on a 365 or 2016 machine? it those functions will not work on 2016.
it can prob be done another way. but will take time to build that formula
 
Upvote 0
are you doing this on a 365 or 2016 machine? it those functions will not work on 2016.
it can prob be done another way. but will take time to build that formula

Hi awoohaw, me and everyone in my organization uses MS Office Prof. Plus 2016. Then it is clear why we cannot use these functions. Thanks.

I will try to make another veryhidden sheet in my excel, where it will match username&week in data, and then a dynamic list showing the remaining weeks for that user, and then in the "Forms" sheet the user will be able to select only those remaining weeks in dropdown data validation.
 
Upvote 0
OK. I see that you have 365 listed as one of your versions. That is why I asked. But, you gotta play with the toys you have!
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,124
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top