Excel Show Data Based on user Choice - excel

Excel 2007: I get my data from Access tables the Excel sheet is called "Data". My Excel report cells are populated by linking to those data cells(=Data!A1) and some report cells have simple code. But my question is this; my report needs to specify one record. Example: Data record 1: Name=Joe, Birth=7/29/62, Country=USA: record 2: Name=Sam, Birth=4/13/74, Country=China... How do we control the report display to a specific record? If I add a DropDown or ListBox, how do we make only the records for the name picked show in the report. Is there a way to put the code behind the listbox, or should I scrap the list and create a macro, what is the best way for a user to pick the data to be displayed on the report? Suggestions please...

There are two approaches I would use.
When you embed a query object in Excel (which is, I assume, how you are fetching the data from Access) you have the ability to edit that query in the little Query Editor tool.
You can add criteria to that query in this tool - there's a filter icon, you select let's say the Name column, and then type "Sam" in the box below, and that will produce a SQL statement that now includes "Where Name = 'Same'" at the end.
However, that's not that helpful for reporting, since most likely we want the name to be a parameter passed in from the Excel sheet itself. If in the criteria box, you type "[enter name]" instead of "Sam", the square brackets tell the Query tool that this is a user supplied parameter. When you run the query from the tool now you get a pop up box asking you each time for the name.
Now when you exit the query tool and return to Excel, you can edit the Query Parameters for that embedded query object. The parameter you made (name) is there, and it can either take on a static value, prompt the user, or take the contents of a cell. You can even set a flag to refresh the query when the cell contents change.
The other approach goes a little further and manipulates the query object in some VBA code. If you need to do some heavier lifting, or other logic, for example, and you don't want to deal with writing it all out as spreadsheet formulas. An easy way to do that is to drop in a button on the report sheet and have the VBA code start on that button's click event.

Related

Editing data through a filter in Excel

I have a large imported .csv as a (Query) table in an Excel workbook. I'd like for users of the workbook to be able to select a small subset of that data and update some values without having to play around with filters on the table.
To that end, I've set up a FILTER on a separate sheet, something like:
=FILTER(my_table[some_column], my_table[id_column]="some value")
That pulls in values from the relevant column and displays them.
My question: is there any way to allow users to edit the values retrieved with the FILTER, so that the changes are reflected in the original table? Attempting to edit such a value now just edits the underlying field, causing the FILTER to update and display #SPILL! (which makes sense, since there is not enough free space to render the result).
I've looked at options for FILTER, and thought about writing some custom VBA code to do what FILTER does "manually", and then watch the sheet for updates in that range - but that seems like a lot of coding to do something I would imagine is more commonly needed?
Am I going to have to code this up in VBA? Or is there some alternative approach to using the FILTER?

Excel: Querying Web/Sharepoint in Drop-Down

I am trying to create a very small Excel file which queries an Online/Sharepoint Excel file.
I don't want to import all the data as this increases the final size of the document (I know I can make a VBA Macro to delete the data but I can't reply on the people using the spreadsheet to run this macro).
Ideally, I would like to have each section in a drop down list; ie 1st Drop Down selects category of item, which directly influences the 2nd Drop Down of Manufacturer which directly influences Model etc. with each section only being queried as it is required.
Is this possible?
Thanks,
Ryan
you can ask your macro to be triggered on an automatic event without replying on the user.
Could you define : category, item, Manufacturer, Model and section?
with words like : Sheet, Workbook, Row, Range
Or And give a sample spreadsheet

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

MS Access - Data in top row appears and disappears when focus on the cell changes.

Its a bit of a weird one but I have a linked table within my database. The table is an excel table with identical field headings and data types and until recently has worked fine however now when I traverse the linked table in Access the data will change every other move, changing from the original row to show data in the row below. Iv had a script output the values of the top row and it displays normally however I cant append this linked table into anything and I assume its this glitch.
Im stumped and would love any ideas as to how this happened and how it can be fixed.
This is an unusual post as I've never quite heard of this type issue. To sanity check things I would suggest that you delete your excel table from the navigation pane in Access - and then relink it.
So then perhaps I didn't understand, and I am wondering what is meant in your first post by: "The table is an excel table with identical field headings and data types"
A link to excel is a qualified "table" so to speak. You should be able to double click on it within Access, it opens in data sheet view and you see all the data but you can't write to it. You can't write back into the excel.
You can query it....
You can append the query results of the excel into a true Access table.

Import a single value from Access into Excel (without the column heading)

I would love to know how to import a single value from my Access database into an Excel cell.
Alternatively removing the header would be a good start.
The query
SELECT SUM(DEMANDS) AS TOTAL FROM [DB PROD]
gives me a header named TOTAL and, right below it, the sum I'm interested in. I use this query from within Excel (Data > Get External Data > From Access). How can I only get the sum in a single Excel cell?
One way to accomplish your goal would be to put your existing query on a different Sheet, say Sheet2, so the column header appears in Sheet2!A1 and the value appears in Sheet2!A2. Then reference the value cell from elsewhere in the Excel document. (The formula will look something like =Table_test.accdb[TOTAL].)
If you had several queries you could presumably keep them together (side by side) on the same sheet. You could also hide the query sheet so the "magic" would be more transparent to the user.
I am not sure I understand what you are doing, but, in order to read Access data from Excel, you need to do the following:
programmaticaly open a connexion in your Excel code, pointing to your
access database (let's say an ADO connexion for example)
then execute your 'SELECT' through this connection, using the ADODB.command object. That will return the requested value
another option would be to open a local recordset in Excel,based on your SQL intruction, and read the value.
Then do not forget to close your connexion

Resources