I have a dropdown menu in cell A1 with different mode options (ex mode A, mode B, mode C) and next to this theres another drop down in cell A2 where the user can enter the level they want (ex. level 1, level 2, level 3). Then, theres a cell (B2) where they enter a number between 1 and 3. I would like a pop-up message to appear when the user clicks on B2 and the options are set to mode C and level 2 or 3. So far I have been using this in the data validation box but the input message appears all the time, even if the specified modes/levels arent there. The data validation is in cell B2
=AND(ISNUMBER(FIND("mode C", A1)), OR(ISNUMBER(FIND("Level 2", A3)),ISNUMBER(FIND("Level 3", A2)))
Joey,
I got some workaround to solve your issue. see below -
i defined the formula in one cell(for custom validation purpose) that will give me output as TRUE & FALSE
=IF(AND(A1="Mode C",OR(A3="Level 2",A3="Level 3")),TRUE,FALSE)
Let assume i have this formula in Cell B1.
Now My Custom Validation formula will become like below for Cell B2 -
=$B$1=FALSE
Thats All.
Related
on the below Schedule image I am trying to create a Drop Down List in the "Gland (A)" Column. Rather than just creating a list of all available "Glands" I want that list to be filtered based on the data within "CORES / PAIRS", "SIZE mm" and "CABLE TYPE". For this example we will use a "3c 16 BS5467, XLPE/SWA/PVC".
Schedule
To determine the filter for the list, the "ID Ø (mm)" and "OD Ø (mm)" for the select cable need to be taken in to consideration, see Cables image below. As you can see for the example we are using the cable has an "ID" of 15.5 and "OD" of 20.35.
Cables
Finally seen below in the Glands image, the "ID" from above needs to be within the "INNER MIN/MAX" and the "OD" needs to be within the "OUTER MIN/MAX".
Glands
So back to the first image in the "GLAND (A)" columns for row 4 the drop down list should be filtered and only show concatenated values:
151/RAC/B/M25
501/453/UNIV/B/M25
ICG/653/UNIV/B/M25
In two separate formulas I managed to VLOOKUP just the "OD" based on the cable types:
=VLOOKUP(B4&C4&E4,'Cables'!A$2:H$169,8,FALSE)
Then based on the retrieved value LOOKUP the "GLAND SIZE" from within the "OUTER MIN/MAX":
=LOOKUP(2,1/((F4>='Glands'!E$3:E$9 + 1)*(F4<='Glands'!F$3:F$9 - 1)),'Glands'!B$3:B$9)
The problem is I don't know how to include checking the "ID" as well, also to retrieve concatenated cells ("GLAND TYPE" and "GLAND SIZE") and then for them to be a Data Validation Drop Down List.
Any help with this would be greatly appreciated.
Thank you
Ok, this is going to be hard to explain. I'll do my best. Maybe if we wrap this up in a dedicated sheet we won't make mistakes.
PHASE 1: create a new sheet.
Create a new sheet and name it "Calculations". We will put most of the stuff here. First of all we type "Selected row in Schedule" in the cell A1.
PHASE 2: determine what cable number is selected.
Since we have multiple entry of cable in the Schedule sheet, we will need multiple list of possible glades. Creating a dedicated list for each lane or costraining the user freedom would be unpractical. Therefore we need to know what row the user is selecting in the Schedule sheet. We have to use VBA. Right-click on the Schedule sheet name tag and click on "View code". Copy-paste this code in the window that has appeared:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Filling the cell A2 in the sheet Calculation with the row number of the selected _
cell in the scheet Schedule.
Sheets("Calculations").Range("A2").Value = ActiveCell.Row
'Preventing multiple selection in the F column of the sheet Schedule.
If Not Application.Intersect(Target, Range("F:F")) Is Nothing Then
Target.Resize(1, 1).Select
End If
End Sub
This code will report in the cell A2 of the sheet Calculation the row number actually selected in the sheet Schedule. Everytime the selection is changed, the value changes. It also prevent the selection of multiple rows of the F column in Schedule sheet (the column where Glades dropdown list will be placed). You can test the code by changing the selection in the Schedule sheet and looking at the result in Calculations sheet.
PHASE 3: determine what type of cable is selected and its ID/OD.
In the Calculation sheet, type "Selected cable" in range B1. In range B2 type this formula:
=INDEX(Schedule!$A:$F,Calculations!$A$2,2)&INDEX(Schedule!$A:$F,Calculations!$A$2,3)&INDEX(Schedule!$A:$F,Calculations!$A$2,5)
This formula reconstruct the name we will search in the LOOKUP column of the Cables sheet. It's a series of INDEX functions, nothing really complicated.
Now that we know what to look for, we can extract its ID/OD. Type "ID" in the cell C1 and "OD" in cell D1. In cell C2 type this formula:
=VLOOKUP($B$2,Cables!$A:$H,7,FALSE)
In cell D2 type this formula:
=VLOOKUP($B$2,Cables!$A:$H,8,FALSE)
These formulas will search the cables' list in the Cables sheet and extract the ID/OD of the given one.
PHASE 4: create the filtered list.
Your glands' list has its first gland in the third row. So just to make it easier to crosscheck the data, we will place our formulas accordingly. In sheet Calculations type "List stage 1" in cell E2. In cell E3 type this formula:
=IF(AND(C$2>=Glands!C3,C$2<=Glands!D3,D$2>=Glands!E3,D$2<=Glands!F3),ROW(),"")
Drag it all the way down until it will be cover the same number of rows of the glands' list in the Gland sheet. This formula will "highlight" in what rows are the glands we are looking for (if there are any). At this point the list is very long, unsorted and presumably has a lot of blank cells. We need to sort it. In cell F2 type "List stage 2". In cell F3 type this formula:
=IF.ERROR(SMALL(E:E,ROW()-ROW(F$2)),"")
Drag this one down just like the previous one. Now we have a compact list of numbers. We need to translate them into glade's names. In cell G2 type "Filtered gland list". In cell G3 type this formula:
=IF.ERRORE(INDEX(Glands!A:B,F3,1)&"/"&INDEX(Glands!A:B,F3,2),"")
Drag it down again like previously did. We have our list.
PHASE 5: name the list.
We need to create a dynamic reference to the list to cut out all the blank cells. Define a new name calling it Gland_Filtered_List referred to this formula:
=INDIRECT("Calculations!$G$3:G" & ROWS(Calculations!$G$3:$G$1048576) -COUNT.BLANK(Calculations!$G$3:$G$1048576)+2)
PHASE 6: insert data validation.
In the Schedule sheet, create a data validation for the glands column using the list mode and Gland_Filtered_List as origin.
That should do the trick. Right now i have to hurry for work, so i can't check the explanation. Everything should be in order. Try this and ask any question. I'll answer later.
I have created small excel form for updating a database. works great, though staff are doing odd things and have to replace the excel weekly with a clean version. So I am thinking of creating userforms that update the excel sheet(DutySelection).
I have many buttons (userform) A4:A31 that will control a single macro which opens 3 different userforms depending on B4:B31 dropdown list selection
Currently My code only works from B4 no matter which button i click.
EG: B4 selection Start, the Start form opens. B6 selection Finish, the Start form opens
Sub Duty()
If Sheets("DutySelection").Range("B4,B31") = "Start" Then
frmStart.Show
ElseIf Sheets("DutySelection").Range("B4,B31") = "Duty Type" Then
ReportUpdate.Show
Else: Sheets("DutySelection").Range("B4,B31") = "Finish" 'Then
frmFinish.Show
End If
End Sub
I am thinking that i am missing a line or two but just can not find what i am needing online
Sheet.Range("B4,B31") doesn't return what you think it does: it returns a composite range consisting of 2 areas, area 1 being cell B4 and area 2 being cell B31. I.e., the same as you would get when you select cell B4, then Ctrl-Clicked cell B31.
I think you meant "B4:B31", but this also returns something else: an array filled with (the values of) all cells in the range B4 to B31. You cannot compare it with a text string just like that.
What you do want here is to loop through all cells between B4 and B31, then compare their values to the texts you're interested in.
Another issue is that your code only ever acts upon the first text it matches. So, if cell B4 contains "Start", then there's no way the ElseIf will ever be evaluated, not even if cell B5 contains "Duty Type". The best way to deal with this depends on how you get those texts in column B on your sheet.
If I understood you correctly, you have a button in each row next to column B and clicking it invokes the action selected in column B in the corresponsing row, right?
In that case I would suggest that you place 3 buttons next to each other that invoke 3 different macros.
Greetings,
vat
I have a cell that looks up a table on another worksheet. Can I popup a message with text from that table when the cell is selected?
For example, Cell D2 is a drop down menu reading data from sheet2/Column 'A' which has choices 1, 2, and 3. If the user chooses 1, I would like a pop-up message explaining what that choice is. sheet2/Column 'B' has the description for the items in Column 'A'. If they choose 2, then the explanation from column B will popup.
E2 would be a sensible place, try there:
=IF(ISBLANK(D2),"",VLOOKUP(D2,Sheet2!$A$1:$B$3,2,0))
I want to show pop up message to the user for the following scenario in Excel Sheet
In Excel Sheet, If values in A1 and A2 are not equal then the message should pop up with some entered text like "The value in A1 should be > A2") which guides user entering correct value.
Please let me know.
Thanks!
The easiest way to do this, is using the inbuild data-validation of excel.
You find it on the data-tab on the ribbon-menu - looks like this:
You would need to set it up as "user defined" and specify your formula as =A1>=A2.
Further you can setup your "The value in A1 should be > A2" message to be displayed on cell-selection (input message) or as the pop-up messeage on entering a false number (error alert).
You will need to setup this data-validation for both A1 & A2, in order to have it displayed on any change of their relation.
The scenario is as follows,
I have a list of options to be filled in one cell, say A1. The options can be filled using Data Validation-List which causes a dropdown to appear in A1. Now I want B1 to contain a dropdown, the entries in which change on the basis of the data in A1.
As a contrieved example, suppose A1 offers the choices Mammals, reptiles and amphibians. If I select mammal, I should get man, cat, dog as an option in B1. If I select Reptiles, snake and lizard appear as an option in B1. If I select amphibians, I should get Frogs and toads.
I would like to avoid using VBA for this.
Use the INDIRECT formula in the validation list as is clearly explained here:
www.contextures.com/xlDataval02.html
Here you go, a solution completely without VBA. It's using actual combo box controls from the "Forms" toolbar:
Add three extra worksheets to your workbook. I called them "domain", "data" and "animal"
on sheet "domain", I did:
enter (from cell A1 downwards) "mammals", "reptiles", "amphibians"
defined a name for range "domain!$A:$A": "Domain"
defined a name for range "domain!$B:$1": "DomainChoice"
on sheet "data", I did:
enter (from cell A1 downwards) "man", "cat", "dog"
enter (from cell B1 downwards) "snake", "lizard"
enter (from cell C1 downwards) "frog", "toad"
on sheet "animal", I did:
in A1, entered the following formula
=T(INDIRECT("data!R" & ROW() & "C" & DomainChoice; FALSE))
filled this formula down to, say, row 50.
defined a name for range "animal!$A:$A": "Animal"
defined a name for range "animal!$B:$1": "AnimalChoice"
on the main worksheet, I created two combobox controls:
in box 1, I defined the properties ("Format Control...") as follows:
"Input range:" - "Domain"
"Cell link": - "DomainChoice"
in box 2, I defined the properties as follows:
"Input range:" - "Animal"
"Cell link": - "AnimalChoice"
Now should "mammals", "reptiles", "amphibians" appear in box 1, and the contents of box 2 should change based on the selection.
Look at the various sheets to see what happens behind the scenes. The only requirements are that the order of the values in the "domain" sheet corresponds to the columns on the "data" sheet, and that can only be as many animals as there are rows filled with the formula on the "animal" sheet.
You can hide the three helper worksheets, if you want.
The formula, explained:
T( // returns an empty string unless the argument is a text value
INDIRECT( // returns the value at the given reference string
"data!R" // build a dynamic reference string to "data!R1C1"
&
ROW() // the current row, changes as you fill down the formula
&
"C"
&
DomainChoice // defined name of "domain!$B:$1", contains box 1 choice
;
FALSE // flag to indicate that the formula is in "R1C1" format
)
)