conditional copying in excel - excel

hi
i need some help with vba.
i know that when you want to copy excel cells based on a condition, you do so by right clicking the sheet and entering the visual basic screen.
thing is, i'm not very familiarized with vb. i've read some similar posts but haven't been able to understand them completely.
this is what i want to do:
i'm making a workbook for chemistry students to illustrate surface tension. what i did was give them 5 different substances to choose from.
i already have data from reliable sources, so calculations are not a problem.
thing is, i want to display the results on graphs. i only want them to choose 2 different substances at a time, so i only want to display 2 graphs.
i don't know how to copy the data from the substances they chose.
thanks!

I can help you; you need to be more specific. If I understand your question, you have a graph that plots data from one sheet (sheet A), another sheet that contains all the data (sheet B), and you want sheet A to contain some of the data from sheet B, based on a condition specified in sheet A (ie, type of substance) and reload the data in sheet A with some data from sheet B based on an event that triggers the moving of the data. Is this about right? If so, I need to know the following.
1) where is the data stored in sheet A to generate the graph
2) is the data the same lenght (ie. all 5 substance data contain 50 rows, for example)
3) what's the trigger to change graph and start the procedure to move data around
4) how is the data stored in sheet B
5) what is the condition
6) what's the trigger
It'd be nice if you could post your spreadsheet online somewhere.

Related

Is there a way to enter, save and delete entire row in a scrollable list and reflect the same changes in main data sheet in excel

Fisrt i would like to state that i don't know much about vba other than what i pick up from the internet and forums like this one. I have a problem and i'm hoping some on this forum will come to my rescue.
I'm trying to create a simple equipment maintenance system in excel. I do not want to use the vba user form Because i do not have much knowledge of vba coding.I have two sheets, Sheet1 (called Form) and sheet2 (called Data). So i have craeted an on sheet form on the left of the sheet1 (Form) which i would like to stay visible at all times So to achieve this i picked up a method from the internet of creating a scrollable list (Displaying all data entries from sheet1 (Form), i have also picked up vba code to save and reflect form entries on Sheet1 (Form) on sheet 2, so far so good. Coming to the problem, i would like to make and delete entries directly on to the scrollable list which would also reflect on the data sheet. Another problem i would like to know if possible is how to make the maximum value of the scrollable can increase automatically as data rows increase.
Please HELP!

Transferring data from one excel sheet to another

I will preface this by saying I have not much experience with excel.
I'm looking to see if there is a way to input data into one sheet and simultaneously transfer the data to different cells in another. The sheets are not formatted the same. The sheets are used for tracking shipment data. Sheet 1 is for a shipping manifest of contents and the second is used as a master tracker to tell what items were shipped when, quantities, truck #, location # etc.
Is this possible given they're of different formatting?

Extracting data from excel using powerquery

I want to extract certain set of rows (let's say rows 10-30) from the same sheet (let's say sheet "income statement") present in multiple excel files to create a data dump (let's say "result") in an automated manner. Also, I want to shape the data in a particular way (basically pivoting and transposing on certain columns). I want to use powerquery (and probably M, if required) for this. Can someone help me with how to go about it, please?

Read excel cell colour into Power BI

I have an excel file that I need to read into Power BI. Unfortunately I have no control over this file as its auto generated from another person.
Some of the cells in this file are just filled with colours and I want to be able to translate these colours when importing the data into Power BI.
For example if the colour is green in excel then show true in the corresponding power BI cell. At the moment it's just blank.
Does anyone know of a way to get cell "meta" data like colour from excel in Power BI?
Don't give up just yet...
I found an example that works in a roundabout way using Power Query in Excel. It will give you the meta data associated with each cell by its address (e.g. A1 is highlighted with color FFFFFF00). I relied on some Excel functions to associate the highlighted cell addresses with the cell values. Pulling the cell data with Power BI might take some additional work.
The technique is to use Power Query to open the Excel .xlsx file, which is basically a .zip file containing .xml documents. The color information for each cell can be extracted into a table. From there I was able to use INDIRECT() statements to read from the .xlsx workbook and extract the values from the colored cells. It worked quite well for me.
You can find a working example in the forum in the link below. The user defined DecompressFiles function in the sample uses the Binary.Decompress command to access the XML files within the .xlsx file.
https://www.excelguru.ca/forums/showthread.php?7047-Extract-Cell-Color-with-M&p=28875&viewfull=1#post28875
In my situation, I had a database export of about 7,000 rows and 50 columns into Excel. Working offline, users then went through Excel and made changes, highlighting every cell they had changed. Then they wanted me to update the database with only the highlighted cells. The background color used by each person varied but I didn't care what the color was, just that it was colored.
For each changed cell I was able to generate SQL statements to update the database and also insert into a transaction log table. The main database table was mostly flat but the few foreign key lookup values that were modified I had to update manually.
Column F uses the Indirect formula to pull data from the source workbook. Note that the source workbook must be open for the Indirect formula to read from it.
=INDIRECT("'[" & Import_Filename & "]" & Sheet_Name & "'!"&[#[SheetCellRef.2]])
Column G refines the data in Column F by putting quotes around strings or NULL if the cell is blank.
Column H grabs the column heading to know what field to update.
Column K grabs the Record ID value from the row specified in Column E.
I have had to run this process three different times for the users so my time invested paid off quickly. All I have to do is put their latest highlighted Excel file in the local folder and refresh the Power Query to generate new SQL statements.
Sorry I don't have a 'solution' posted right here. The process is still a little fragile and I'm trying to make a more robust example I can share. Stack Overflow doesn't seem to be set up for ongoing development of a solution. The point of this answer is to give hope to some of you who are desperate for a solution and won't take 'No' for an answer.
Sigh.
Color is not data. Unfortunately, many people color-code cells and then expect to be able to do things based on the color of the cell. But it's not that simple.
Although Excel now provides some ways to filter by cell color, it still cannot identify cell color with a worksheet formula.
Hence, you will need a VBA routine that evaluates all cells and records their colors in another table, which you will then need to push into your Power BI data model.
In the long run, it might be easier to talk to that other person who produces the color coded cells, and teach them a better way of doing things. Show them how to use conditional formatting based on cell values for color coding. The logic used for conditional formatting can also be applied to classify the data in Power BI.
From a data architecture point of view, the best solution is to address the problem at the source, instead of creating tools to handle bad data input.
Just sayin'.

Converting Excel rows to columns (smarter than transpose)

I have some data that has been output by an accounting system, but needs massaging.
Each Invoice is output on a row, but the categories of the products on the invoice are output as a column - I want all the data to be on a row.
(I've just discovered that as a new user to here I can't post an image, so this link links to a jpg that explains what I mean)
So the image shows how the data is currently output and how it needs to be. I assume that I need to use VBA to do this (there's actually 1000's of rows of data and a new sheet is generated every day), but I'm interested in any other ideas or samples of what functions to use in VBA (I'm a delphi developer and haven't written anything in VBA for many years, but I'm sure I can turn my hand to it with a few hints!)
Many Thanks
David

Resources