I have a table in MS Access having 4 rows with four columns A, B, C, D
I want to export this records into an Excel sheet as follows,
Expected Output :
8 rows in Excel
How Excel should be like
4 rows will be queried from table
A clone of each row but with Column A prefixed with text 'Dummy'
Other column values for the cloned rows are constant
Example :
Table :
How Excel to be exported :
Each row has been cloned with only column A prefixed with text and rest of the column values are constant
I have few options to achieve in form through VBA and would like to hear which one would be optimised way
-Write a Query to select table values,
-Create a temp table (clone the structure of existing table)
-Loop through the Record-set which has queried values
-Fill the Temp table's first column value with Record-set's A column value with prefixed harcoded text and other column values are hardcoded as well
-append two table and export into Excel
-Query from table and export into Excel
-Loop through table and fill Excel cell A6 with tables field(1) with prefix
-Query from table and export into Excel
-Append the excel with hardcoded values for additional 4 rows (not sure append is possible)
Please suggest which way is possible and happy to hear other options I miss.(Never used MS Access before and this is my first hands on. Based on tutorials I got through, I come with above options)
I would suggest writing a query to select the data then union to that query the second dataset you want. Would look something like
SELECT A, B, C, D FROM tble
UNION ALL
SELECT "PREFIX " & A, "IDE", TRUE, FALSE FROM table
Then output the result of this query to excel.
Related
I usually do my data cleaning in python but the issue with python (pandas) is that when you read and print a table to excel it doesn't retain any of the excel formatting.
In this case I was given a large table where a lot of the cells are color coded and or commented. I need to retain all the coloring, comments, font styles and etc. I don't know how else to do that but to work in excel
The issue:
In one sheet I have a large table (400 rows x 45 columns). It is structured like below
Sheet 1:
|ID|C|D|E|F|
:--|:--|:--|:--|:--|
|EDMU025|1|2|3|4|
|EDMU026|5|6|7|8|
|EDMU027|9|2|3|4|
|EDMU028|5|6|7|8|
In another sheet I have a series of small tables which look like this
Sheet 2:
|ID|Date|C|D|E|F|
:--|:--|:--|:--|:--|:--|
|EDMU025|9/14/22|100|210|300|450|
|EDMU025|9/14/22|100|200|340|400|
|||||||
|Value to be replaced||100|200|300|400|
|||||||
|EDMU028|9/14/22|700|810|900|550|
|EDMU028|9/14/22|700|800|940|500|
|||||||
|Value to be replaced||700|800|900|500|
For each ID in Sheet 2 I need to find the ID in Sheet 1 and replace the values in sheet 1 columns C-F with the Values to be replaced.
The output would be:
|ID|C|D|E|F|
:--|:--|:--|:--|:--|
|EDMU025|100|200|300|400|
|EDMU026|5|6|7|8|
|EDMU027|9|2|3|4|
|EDMU028|700|800|900|500|
What is the most efficient way to do that for the entire table (while still keeping the original values that don't need to be replaced intact?)??
Try nested XLOOKUP() like-
=XLOOKUP(A2,Sheet2!$B$1:$B$15,Sheet2!$D$1:$G$15,XLOOKUP(A2,$A$2:$A$15,$B$2:$E$15,"",0),0,-1)
I have two Excel spreadsheets. On the first sheet is a list of people's names with other data in the rest of the columns. In the second sheet, the first column is linked to the names in the first sheet (using "='Sheet1'!B1", etc); however, the rest of the columns in the second sheet are different types of data from the first sheet. If I want to move a name on the first sheet, this would automatically move the same name on the second sheet, but it won't bring the rest of the data with it. Is there a way to do this so that data follow the name?
I doubt there is an "canonical answer" because the "problem" is not canonical for Excel. In other words: Excel, which is a spreadsheet application, is not made to solve such problems.
Your assumption "the first column is linked to the names in the first sheet (using "='Sheet1'!B1", etc); " is wrong. The formula ='Sheet1'!B1 does not link to names. The formula result is what value is in 'Sheet1'!B1. If that value changes, the formula result also changes. That is exactly what you observe and call a "problem".
Linked tables are typical for a relational database system. There one table may have foreign keys to link to another table. See Foreign key. But Excel is not a relational database system.
There is Power Query to create a data query from Excel Tables which also is able to have foreign key relations between tables. But this is not really straightforward. So let's have a very simple example:
First create a workbook having two sheets having a data table each.
Example
Data of Sheet1:
Name Mail Value1
Name1 name1#example.com 123
Name2 name2#example.com 234
Name3 name3#example.com 234
Name of the Table is Data1
Data of Sheet2:
Name Value2
Name2 2345
Name1 1234
Name of the Table is Data2
Now create a Power Query from Table Data1. See Import from an Excel Table
Select a cell in Table Data1 (is on Sheet1).
Select Data > Get & Transform Data > From Table/Range.
Excel opens the Power Query Editor with your data displayed in a
preview pane.
To return the transformed data to Excel, select Home > Close & Load.
You get an additional sheet having the result of that data query. For me that sheet gets named "Data1".
Now do the same with Table Data2.
Select a cell in Table Data2 (is on Sheet2).
Select Data > Get & Transform Data > From Table/Range.
Excel opens the Power Query Editor with your data displayed in a
preview pane.
To return the transformed data to Excel, select Home > Close & Load.
You get an additional sheet having the result of that data query. For me that sheet gets named "Data2".
Now select the sheet "Data1" (The sheet which holds the first query result) and edit the query. See Create, load, or edit a query in Excel (Power Query) - > Edit a query from a worksheet -> To edit a query, locate one previously loaded from the Power Query Editor, select a cell in the data, and then select Query > Edit.
Now merge queries from Data1 with the one from Data2. See Merge queries (Power Query) -> Perform aMerge operation.
Select Home > Merge Queries.
The Merge dialog box appears.
Select the primary table from the first drop-down list, and then
select a join column by selecting the column header. This is column
"Name" in our case.
Select the related table from the next drop-down list, and then
select a matching column by selecting the column header. This is
table "Data2" and column "Name" in our case.
Select OK.
The result should be an new column "Data2" added to the query "Data1".
Now select the handle at right side of column name "Data2" and mark only "Value2" selected. The coulmn name should change to "Data2.Value2"
To return the transformed data to Excel, select Home > Close & Load.
Result should be the data table on sheet "Data1" cahnged to show the Value2 of Data2 too.
From now on all changes in Table "Data1" on Sheet1 and in Table "Data2" on Sheet2 will be put together on query result on Sheet "Data1" when you refresh that query.
Disclaimer: This answer is for the linked example in Automatically move an entire row of reference cell when one cell is moved or manipulated.
In Google Sheets, you can use the =QUERY() function to automatically move an entire row when one cell on another sheet changes.
Here is an example of how you can use the =QUERY() function to move an entire row from one sheet to another when a specific cell changes:
In the sheet where you want to move the row, create a new column and name it "Status."
In the sheet where the cell that will trigger the move is located, create a new column and name it "Move."
In the "Move" column, use an IF() statement to check if the cell you want to trigger the move is true or false.
For example: =IF(A1=TRUE,"Move","Stay")
In the sheet where you want to move the row, use the =QUERY() function to select the rows where "Move" is "Move" and "Status" is not "Moved".
For example: =QUERY(Sheet1!A1:Z,"select * where Move = 'Move' and Status != 'Moved'")
In the sheet where the cell that will trigger the move is located, use the =IF() statement to change the value of the "Status" column to "Moved" when "Move" is "Move".
For example: =IF(Move="Move","Moved",Status)
Use a script to automatically run the query and update the status every time the cell that triggers the move is changed.
Please note that this is an example and you will need to modify the formulas and sheet names to match your specific use case.
hope this helps
As the question is not really clear about this, there would be another approach if you have the following structure:
Given following data in Sheet1:
ID Name Mail Value1 Value2
1 Name1 Name1#example.com 123 1234
2 Name2 Name2#example.com 234 2345
3 Name3 Name3#example.com 345 3456
Now Sheet2 shall only pull different data from Sheet1 dependent on Name. Then Sheet2 could have following formulas filled downwards from row 2:
A2: =Sheet1!B2
B2:C4: =VLOOKUP($A2,Sheet1!$B$1:$E$998,MATCH(Sheet2!B$1,Sheet1!$B$1:$AAA$1,0),FALSE)
Now you can change data in Sheet1 and Sheet2 will always show the correct data for name because of the formulas.
For instance: I have value 5 in cell A1 and when I do =5+A1 in excel it will do the job for the rest of the columns. How can I do exactly same in PowerBI? could anyone help me with this?
Thanks
Go to Table mode and click New Column.
Type MyColumn = Rates[size] + 5
Where [size] is base column as input (like A in excel) and MyColumn is the name of your new column.
I have two columns:
ID country
1 spain
1 france
1 sweeden
2 mexico
how to concat all the countries with ID 1 and send them to another column like this
ID2 country2
1 spainfrancesweeden
How to do this with an excel formula instead of a VBA code.
I tried this:
=CONCATENATE(VLOOKUP(A18; Hoja2!A19:Hoja2!B24; 2; 1); " ";VLOOKUP(A18; Hoja2!A19:Hoja2!B24; 2; 0))
But it only gets two results (but there are 3)
Layout of sheet:
Do convert your data to table and insert pivot table, on the screen of create pivot table check the option add this data to the data model, now go to pivot table fields and right click on the table name and click on add measure. There would be a window opened in the name of Measure in which you put the measure name and value description as per your choice. Now come to formula area which would start with = sign there you type below formula concatenatex(table1,table1[country],","). Now one additional function would had created in the area of pivot table fields. Now you can drag id into rows and drag the created function into Values. It would show the desired result as follows.,
Row Lables|Joincountry
1 |Spain,France,Sweedan
2 |Mexico
Hope this is order and would help you.
!
[result]1
I have an existing List&Label report containing a table with three columns:
col1 = valueA
col2 = valueB
col3 = valueA + valueB
When exporting these list to excel, the resulting excel table contains only values in all three columns.
Example export:
I tried to enter the formula for col3 as text, but then Excel also interpreted it as text.
Is there a way to export the table with List&Label to Excel, so that I have a working formula in excel?
Unfortunately - no. As List & Label has its own formula language that isnt't entirely translateable to Excel, there is no layer for this purpose - all values are exported as is. I'd export just columns A and B and add the formula to the resulting sheet. If this is something you need to do often/automatically, you could use VBA to post process the sheet. Here is a primer how to do that.
I'm new to List & Label and I'm evaluating it currently for further use. While my research to the product I found this article which describes new feature within the export format to Excel and meanwhile formulas are supported in the latest version - look there: Generating Excel Formulas in Worksheets