In excel is it possible to dynamically (programmatically) display rows that have a speific column value? - excel

I have a row of data. ONe of these fields is updated dynamically. The field is called overdue date. When the document is opened, this field adds 2 weeks onto another field value called date requested, thus coming up with a date.
I would like a function that checks whether this overdue date is the same value or less than today's date (ie is it overdue) and if it is, show this row in another section in the spreadsheet.
Is this possible?

There are 2 ways to do this that I can think of. One is advanced level and the other is expert level.
The first is to use a macro, which records a specific set of actions. So open the file, then record a macro:
Start Recording:go to cell A1, then navigate to the dataset, then sort it, then END Recording. You could put a button on the page and assign the macro to it.
Then, the user would open the workbook, click the button and that's it.
The second way would be to use VBA, there is an event handler for when a workbook is opened that could run that macro, but this is was complex if you are not already familiar with VBA.

Related

How to submit cell data into other cells in excel

Think I might be reaching a bit here, but I’m trying to find a way of sending / submitting cell values in excel to other cells. Here’s the example;
In a cell I have a car name
I’ve set my workbook up to use this cell as a field to enter data and the system calculates where what I enter into a separate table, and returns a confirmation that the car I want to look for exists. I might then delete the data in the field to repeat the search. Here’s what I’m trying to solve…
If the car doesn’t exist, I want to somehow send or copy the data from the field (by clicking something or a formula) and send it into another table automatically to list as “cars that were searched for but didn’t exist” type area, how could I do this?
Many thanks

Value Field add event in pivot table

Background
When the Pivot table seems to have a custom NumberFormat, the created fields will not carry it.
OffTopic: I guess it is normal, sometimes it displays 2, 3 or 5 digits among the same dataset, this is for convience for the user (thus making each cell in the column likely to have a number format different from each), I am not really able to change it, there is another ruling that basically formats cell by cell on the source data (I know it's not ideal, but it is what is convinent for the user and avoids overflooding the workbook with conditional formattings).
I would like to keep that number formatting on the value field when the user adds it to the PT by dragging that field to the Value field.
Problem
I have not found the right event to detect when the field is being added to the Pivot Table, I have tried all the events related to PivotTables in the worksheet, but even by reading to their inputs, I can see that such event may not exist.
Question
Is there an event that detects the field adding?
Further thoughts
I am not quite sure if it exists, my alternative would be to create a button where the user would get the format from the original source by clicking it by using the same code that I use to format cell by cell, but I would like to this be ran automatically when the Value add happens.

How to predefine the required format of a cell?

I currently build a dashboard in Excel to track forex trades. One worksheet is for adding new trades to the database. Within this worksheet i have several fields that the user needs to fill in order to add the trade to the database. Now I want to avoid that the user inserts wrong data (regarding format) in the cells and therefor crashes the outputs from the database later on.
How can I define such criteria via VBA? For example the field date to have the format YYYY-MM-DD and the field Trading Volume XX,YY so the user can't (accidentally) insert X,YY etc. For dropdown fields it is easy by defining the inputs within the dropdown menue itself, but i need some solution for the manually filled cells.
I will then define a msgbox to pop up and inform the user to meet the required input formats.
Thank you very much in advance!
Some key words would help me, I can then get into deeper it and code it by myself.
Rather than using code could you not use data validation and force entry of a date, numeric value etc.?
If you define the cell format to be custom 'yyyy-mm-dd' then apply data validation with a defined date range Excel will auto format it for you even if they enter dd/mm/yyyy and alert if an invalid entry is added.
Then for a belt and braces approach run a routine at Save that will mimic what your database will do and alert if there is still invalid data see https://learn.microsoft.com/en-us/office/vba/api/excel.workbook.beforesave
I would also lock down the sheet to avoid users adding rows / columns or moving your cells around.
enter image description here

How Do I create a Data Validation List based on a filtered TABLE?

I have spent hours searching for an answer and attempted to create my own solution with little pieces of information I gleaned, but I am still no closer to a solution.
Scenario: I have a data table (sorted by index field that I want to use). I have a CRITERIA column and the INDEX column. I have a form worksheet where I want the list to appear. On a second form worksheet I have VBA code attached to a button(s) that filters the data table in-place. On the form sheet there is a SELECTION CRITERIA field that, based on the value selected from the pull-down 'data validation' menu, dynamically populates the form fields from the values on the corresponding row in the data table. (this is accomplished by a VBA event trigger to the cell, and population is accomplished with other VBA code. The event trigger also prompts user to write changes back to the data table if changes are identified from the previous populated form.)
PROBLEM: I want the data validation list on the SELECTION CRITERIA cell to dynamically change based upon the auto-filter triggered by the button selection. (each button runs a VBA procedure that filters the list based upon one or more criteria)
I am most grateful for any suggestions or solutions provided!

Creating a drop-down list in Excel

I'm changing an old Excel spreadsheet and have got a user-request to add a drop-down list to a date selection field.
Data Validation is already turned on for the cell in question with a "<=TODAY()" clause (the sheet contains information on production efficiency, no idea going forward since data is not there).
The user requests a drop-down listing the past seven days. I can make a list and enumerate it in VBA, but I am having difficulties coming up with a way to apply a drop-down list to a cell without using Validation.
Is this possible?
Here are some ways you can try:
Add a datepicker to the cell (and keep the formula validation you put)
a. See some standard way on MSDN
b. or with an addin on this blog
Change dynamicaly your validation to a dropdown list when the Workbook is opened or the worksheet activated with an event procedure and add another event procedure OnChange to check if the value entered is before today.
Why not replace the existing data validation rule with a list rule? Just create a new sheet and enter in A1:A7
=TODAY()
=A1-1
...
=A1-6
Then set your data validation rule to "List" and set the Source to A1:A7 on the new sheet. Then hide the sheet just to keep it out of the way. This should preserve the old validation requirement.

Resources