Forum Discussion

Re: Power Automate/Query Assistance - Add new table in file to bottom of existing/trend assistance

How about this:

Using Power Automate:

  1. 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:

  1. Open the Excel file where you want to append the data.
  2. Press Alt + F11 to open the VBA editor.
  3. Insert a new module by right-clicking on any of the existing modules or the workbook name, then selecting Insert > Module.
  4. 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

 

  1. Modify the code to match your workbook and sheet names.
  2. Run the macro by pressing F5 or assigning it to a button in your Excel sheet.

1 Reply

  • Lorenzo's avatar
    Lorenzo
    Silver Contributor

    Kidd_IpYour Power Automate option looks straightforward and probably enough for this case

Resources