I have a spreadsheet that I will be importing data into from multiple sources and I want to be able to extract the data to other tabs based on the descriptions. For example, I want to pull all of the rows that say "Credit Canadian Deposit Settlement" in Column B and put them into a separate tab so that I can work with them.
Since I have to do this with a large amount of data each week I would like to have as much of it as possible automated so that I can just import that data and then start working with it without too much manipulation. I would eventually like to have a tab for each different description.
spreadsheet sample
This could be done with Power Query:
https://www.excelcampus.com/powerquery/power-query-overview/
Otherwise you it would be better to write a macro. Start by recording a macro using the following steps:
Select cell A1
Insert a table
Filter for one of the descriptions
Press ctrl-A to select entire range
Copy
Paste to the target spreadsheet
Then review and update the code:
Replace any references to a fixed range with a general range, such as:
Range("A1").CurrentRegion
Then you can also insert a loop to run through each possible value. Search/ask for help on writing loops in VBA for further info.
Related
Is it possible somehow to do the following in Microsoft Excel?
Every list has a single table with its own Header:
Table may be of any size, and number of such lists is unknown in advance.
I need to gather all those tables in the very first list which is called "Main" so that each table just followed by another like this:
I need it only for printing, so sorting and another stuff like this is unnecessary.
Microsoft Excel - 2019.
I think you can achieve what you are after using named ranges per this video.
The ranges are then accessible from the dropdown to the left of the formula bar.
I find it easy to select area of tables first, then define a named range based on currently selected area, rather than entering it in the prompt per the video.
1. Insert -> Name -> Define Name
If you have a workbook with multiple sheets you can define names on any sheet, So lets's say table1 was in sheet1, and table2 in sheet2. If sheet1 was the active sheet, you could still select the named range of table2, and Excel will automatically flip sheets for you and select that area as if you had just highlighted the region.
Later when it comes to printing, select the named area, and the say
2. File -> Print Area -> Set Print Area
Then do:
3. Print and instead of selecting Active Sheet use Selection
(I am talking about doing it on a Mac V16.22 - but should be similar on Windows too)
EDIT:
There is IMPORTRANGE in Google Sheets.
Not sure if something similar in Excel was what you were after.
So take a look at this too.
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'.
I thought there would be a simple way of doing this, but unfortunately I have not come across one. My company has an Excel workbook with 12 sheets (1 for each month), into which I enter sales data as accounts are written. I reformatted each month's data into tables, thinking that this would provide an easy reference to gather the data into a pivot table that joins all the months and would be updated as I enter data; however, a pivot table based on multiple sets of data allows highly limited manipulation.
So what I want to do is create a new table that is automatically populated as I enter data in any of the 12 current tables, to combine them into a master listing. I have tried doing a query, but when I try to set up the data sources, it doesn't recognize my tables. I tried Power Query, but I couldn't get it to update the data as I updated the source. Consolidate also was not a useful feature, as it required all the data to be somehow calculated, and my columns need to simply be copied over, not summed or averaged.
As you can probably tell from my explanations and terminology, I'm no Excel expert. I don't know what VBA even is, let alone know how to use it, but I've seen it mentioned a lot, so I figure at some point in my life I should learn it.
Is there a formula or some other Excel 2010 feature that can automatically copy all of this data onto one running list, and keep it updating as I enter data in the source tables? It would have to run automatically.
I believe your end goal is to have a pivot table which consolidates data from each of the individual 12 sheets/tables and not really to have the intermediate "single running list which is an aggregation of all the 12 sheets".
If so, I suggest to create an Excel Pivot table directly based upon the 'Multiple consolidation ranges'.
To start, create a new spreadsheet and select a cell (say A3) and use the click sequence Alt+D+P, this will bring up the PivotTable and PivotChart Wizard, and proceed further using the third option - 'Mulitple consolidation ranges'.
I will have to refer you to the below site for a detailed step by step instructions on the above: http://www.contextures.com/xlPivot08.html
Please be aware that the Difficulty level for this solution is Medium, suggest you to bookmark the solution from maintainability reasons, in case you choose to implement it.
I have two tables A and B that have a different number of columns, with absolutely no match between the columns names but one differentiator (let's call it ID).
I'm programming a macro in SAS, so that it outputs an excel file such as:
each sheet within the excel is corresponding to an ID.
within each sheet, I have:
content of table A
empty line
content of table B
The problem is that I can't append rows of data in SAS because columns are non matching.
Any thoughts?
Thanks for your help!
You can use DDE for that - Dynamic Data Exchange Protocol. Basically what it does is simulating user's commands and clicks on various menus and buttons in Excel (and also in Word and some other applications) - or, more exactly, issues commands on now obsolete Macro Language for Excel ver. 4 (X4ML).
So, using DDE, you can in SAS program launch Excel, open or create workbook, create tabs (spreadsheets), put your data into specified cells range, format any single cell or range etc.
Here's a good intro into this topic:
http://www2.sas.com/proceedings/sugi26/p011-26.pdf
I need to find a programmatic way to do the following. Basically, I have a text file with the followoing:
Of course, there is real data in there and there are several thousand different "chunks" like this. First, we would like to collapse Job Title 1 and Job Title 2 into a single line. Then, we need to import this into excel in a row format. Such as:
I've tackled a similar problem at my job, and the data can actually be manipulated purely in Excel. Your first step is to just get it into Excel, open it in Notepad - copy, then paste into Excel - or optionally try to open it. The trick is to use the "blank row" as a trigger for a set or formulas that you just fill down. When it's done you copy all the results over to a new worksheet, and sort so all the blank rows get thrown away. You'll have to hack away at your data and merge the various results next - but that wont be too hard because you should get 3 different kinds of rows (those with 1 job, 2, 3) .. just fix them with a unique formula each. Hopefully this gives you an idea of how to get started: