Forum Discussion
GRobertsVM
Nov 28, 2024Copper Contributor
Power Automate/Query Assistance - Add new table in file to bottom of existing/trend assistance
Forgive me if this has been answered elsewhere, I have had a look and not been able to find! Essentially, I have set up a flow using Power Automate that saves an XL I receive via a scheduled email...
Kidd_Ip
Nov 29, 2024MVP
How about this:
Using Power Automate:
- Create a Flow to Append Data:
- Trigger: Use the same trigger you have for receiving the email.
- Action: After saving the Excel file to SharePoint, use the "Get rows" action to read the data from the new Excel file.
- Action: Use the "Add a row into a table" action to append each row from the new Excel file to your existing Excel file.
Using Excel Macros:
- Open the Excel file where you want to append the data.
- Press Alt + F11 to open the VBA editor.
- Insert a new module by right-clicking on any of the existing modules or the workbook name, then selecting Insert > Module.
- Copy and paste the following VBA code into the module:
Sub AppendData()
Dim wsSource As Worksheet
Dim wsDest As Worksheet
Dim lastRow As Long
Dim nextRow As Long
' Set the source and destination worksheets
Set wsSource = Workbooks("SourceWorkbook.xlsx").Worksheets("Sheet1")
Set wsDest = ThisWorkbook.Worksheets("Sheet1")
' Find the last row in the destination sheet
lastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Row
' Find the next empty row in the destination sheet
nextRow = lastRow + 1
' Copy data from source to destination
wsSource.UsedRange.Copy Destination:=wsDest.Cells(nextRow, 1)
End Sub
- Modify the code to match your workbook and sheet names.
- Run the macro by pressing F5 or assigning it to a button in your Excel sheet.