Formula-based list for data validation - vba

Please refer to the image attachment below. I want to ask for help regarding the semi-automation of the values D2:D6. Currently, they have the following formula:
=IF(C2="n/a",$D$12,IF(C2="","",IF(OR(TODAY()=C2,TODAY()>C2),$D$11,$D$10)))
Column C on the other hand has the following formula:
=IF(B2="n/a","N/A",IF(B2="","",$B$8-$B2))
Basically, what these formulas do is that after I input a value 'x' at column B, column C automatically indicates the date 'x' days before the start date on B8. Column D then indicates whether the deadline is due, not due, not applicable, or ready (D2:D6 is data validated with a list including D9:D13).
However, if a certain action is already completed, the "Ready" option is manually selected from the drop down list, which then erases the formula. What I wish to ask for help with is how do I return the erased formula in case the "Ready" option is just accidentally selected, or if my (not excel-capable) peers will need to reuse the form by just deleting items in column A and B.
What I tried doing was making the formula itself an option in the drop down list, but this doesn't adjust to the cell addresses for each item, and only shows one static value.
One option I thought of was to limit the data validation list with just the "Ready" option, so that the user can just delete the cell. A VBA code will then detect the blank cell and will return the formula it initially had. Unfortunately, I don't really know VBA or any programming. I can however understand and have managed to use and modify VBA codes posted in the internet according to my previous needs. I tried searching for a code, but to no avail.
If you could give me good references (not a whole book please) relative to this, I would really appreciate it. If you're feeling benevolent and help me with the coding, thanks! However, if there's a non-VBA solution, then I would really like to know more about this. Thanks all!
Sample list

Related

Multiple criteria for index match

=INDEX([Book1.xlsx]Sheet1!$F:$F,MATCH(S2&B2,[Book1.xlsx]Sheet1!$E:$E,0))
Used this formula to pick 2 criteria i.e, data code and record type to arrive at GL account. But the result is #NA error. Also, used concatenate formula and merged the criteria and did vlook up but the error #NA still remains. enter image description herePlease suggest.
Your question is not very clear. I will assume that the table you pasted a picture of is the table you want to RETRIEVE "GL Account" from. I'm not sure why this table would already have an #N/A in it, but know that if you have an #N/A in your lookup table, it's possible for a correctly working formula to return an #N/A, because that's the value it found.
I used tables/columns with intuitive names to make it easier to follow the formula:
=INDEX(LookupTable[GL Account],MATCH([#[Value to use in lookup]],LookupTable[Lookup Value],0))
I don't see anything fundamentally wrong with the formula you posted, but it's just not clear what you are doing with it, what data is in which cells, etc. But hopefully this helps you.

Use One Cell to Add Values to a Named Range

We are trying to allow the end-user of this Google spreadsheet to be able to add values to a Named Range without accessing said range. (Sorting it will be a q for a later date)
In other words, let's say that we have a list of Suppliers that we purchase parts from, and that list resides on 'SheetLists' in cells A1 to A119.
To make that list easier for later use, we made it into a Named Range and named it "list1Supplier".
We then use that "Named Range" throughout the Workbook in drop-down lists. Each of the drop-down lists reference the "Named Range" and NOT cells A1 to A119.
We also realized that, should we begin using a new Supplier, the list could grow. So we changed the Named Range reference to cells A1:A, thus including the entire A column.
Now, as expected, one of the end users begins using a new Supplier. The LAST thing we would EVER want is for them to have to figure out how to add said Supplier to the end of that list MANUALLY... right!?!?
I've googled this for hours and have found NOTHING except ONE using VBA. And unless someone has a REALLY easy to follow How-To on VBA basics, I'd like to try this route first...
As always, ANY and ALL help is GREATLY appreciated!
DG
Why you just don't create a live form?
https://www.youtube.com/watch?v=wNMdjVxAEYY
Best

How do I prevent unlocked cells from being selected/editable? (VBA)

I have a very specific question that I am looking for help in answering. I have been researching for hours and I feel like I am not able to find what I am looking for. Below is a quick overview of the criteria that my document must follow:
I am using Excel 2013
I will just be using rows for data input (instead of an excel object
table).
The very top/first row will act as my "column header".
This top row will have AutoFilter enabled.
THE DOCUMENT MUST BE PROTECTED (a must-have)!
I will be using VBA code
Now, the final issue I am having with finishing this document are the last two criteria points that I must have:
The first/top row (column headers) must NOT BE EDITABLE.
Each column must be able to SORT AND FILTER.
Now, in a perfect world, I would just "Lock Cells" for the entire first row that acts as my column headers and when I protect the worksheet I would make sure to check the "Sort" and "Use AutoFilter" boxes.
However, this option does not work because there seems to be an issue when I try to sort the data. If I just filter the data there is no problem, but when I try to sort a column in ascending/descending order I will get an error informing me that I can't sort locked cells while in Protected mode. This is because when excel uses the Sort function, it counts the header as part of the data that is being sorted (I found this out through my research) even though I really just want the data below it to be sorted.
I have been trying to brainstorm on how to get past this issue as well as researching different methods, and I am having trouble coming to a final conclusion. However I have narrowed it down to 2 possible solutions:
I want to be able to keep the cells in the first row officially unlocked to allow the AutoFilter's sort command to work as intended, but make it "behave" like the cells are locked when a user tries to make changes to it (AKA, make the entire row un-editable or un-selectable).
The other option would be to keep the first row locked but somehow have an event in VBA that can tell when a user tries to "Sort" the column, which will then temporarily unprotect the worksheet, follow through with the intended sort command, then protect the worksheet again (apparently though, upon my research there is no such event that can trigger off the AutoFilter's sort command alone).
These 2 solutions are the most logical I can think of based off my research, but if someone out there is an Excel genius and knows another way I am open to suggestions.
Thanks in advance for your help/suggestions,
Travo
Consider using two header rows. The top row would be protected and the second row would facilitate filtering and sorting of the data in rows 3 and below.

VBA to transfer a figure from one sheet to another based on matching values other col

I am working on a spreadsheet which is being used to transfer a product from one location to another. Each day I will have a new list of products that needs sending to another location and I already have a "pre-populated" sheet that has suitable locations listed for where these products can be sent to.
I've already worked out the formula's to use which defines the location these products can be sent to (through index and match formula) but once this has been completed, I'd like to update the "pre-populated" sheet with the quantity I'm sending these locations so that limits can be deducted accordingly.
Essentially, I want to copy the figure from column G in ("Task") into column I in ("interstore transfer") where the two "REF" columns in either sheet match. The "New Limit" column will then automatically populate with the new limit based on the figure input into Column I. Once its finished working its way down the list in the sheet ("Task") then end.
I've had a rough attempt at this, but I'm coming stuck with defining the appropriate variables and how it should update.
Any ideas to better my approach would be appreciated.
A VBA solution with variables may not be your best approach for this. Variables declared within VBA code usually have a limited lifetime based on their scope, so when the code ends the values in the variable will be lost.
Another alternative may be to set aside another cell as a counter. Perhaps a good place for this would be next to the "New Limit" column?
Cell values are retained even when VBA code isn't running. Of course cell values also are saved when the workbook saves, so when you get a new list of products at the beginning of the day you can compare to or edit the previous day's work.
To get started with this, I'd recommend getting familiar with how to reference cells and ranges. And, there is some useful information here on Stack Overflow on how to reference well in Excel VBA.

Excel - How do I find all relevant rows by typing unique invoice# listed Col A

I have a Worksheet with 10 columns and data range from A1:J55. Col A has the invoice # and rest of the columns have other demographic data. Goal is to type the invoice number on a cell and display all the rows matching the invoice number from col A.
Besides auto filter function, the only thing comes to my mind is VBA. Please advice what is the best way to get the data. Thanks for your help in advance.
Alright, I'm pretty proud of this one. Again avoiding VBA, this one uses the volatile formula OFFSET to keep moving its VLOOKUP search down the table until it's found all matches. Just make sure you paste enough rows of the formula that if there are many matches, there's room for all of them to appear. If you put a border around your match area then it would be clear if you ever ran out of room and needed to copy down the formula some more.
Again, in the main section, it's just a single formula (using index):
=IFERROR(INDEX($A$1:$J$200,$M3,MATCH(N$2,$A$1:$J$1,0)),"")
This gets to be so simple because the hard work of the lookup is done by an initial column which looks up the next row that matches the invoice number. It has the formula:
=IFERROR(MATCH($L$2,OFFSET($A$1:$A$200,M2,0),0)+M2," ")
Here is the working example that goes with those formulas:
Let me know if you need any further description of how it works, but it mostly uses the same rules as above so that it's robust in copying and moving around.
I've uploaded the Excel file so you can play with it, but everything you need to reproduce this feature should be in this solution.
Google Docs - Click link and hit Ctrl+S to download and open in Excel.
A popular solution to this problem is a simple VLookup. Lookup the invoice the user types in on the table A1:J55, and then return an adjascent column's data.
Here's an example of it working:
The formula in the highlighted cell is:
=VLOOKUP($L3,$A:$J,MATCH(N$2,$1:$1,0),FALSE)
What's nice about this formula is you only need to type it once and then you can copy it across and it'll automatically pick out the correct column of the table (that's the match part). The rest is very simple:
The first part says lookup value $L3 (the invoice number typed in),
The second part says look it up in range $A:$J (which is where your table is located). I've shown how you can select the entire columns $A:$J so that you can add and remove data without worrying about adjustin the range in your lookups. (Excel takes care of optimizing the formula so that unused cells aren't checked)
The third part picks the column from which the resulting data will be drawn once a matching row is found.
The FALSE part is an indication that the invoice number must match exactly (no approximate matching allowed)
The $ signs ensure that fixed ranges like the location of your source table ($A:$J) and your lookup value ($L3) don't get automatically changed as you copy the formula across for multiple columns.
The formula is pretty easy to adapt if you want to move around your table and the area where you do your lookup. Here's an example:
Bonus
If you want to add a little spiff, you can add a dropdown to the Invoice # field so that the user gets auto-completion and the option to browse existing values like so: