web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Excel spreadsheet - ho...
Power Automate
Unanswered

Excel spreadsheet - how to group data

(0) ShareShare
ReportReport
Posted on by 2

I'm trying to work out the best way to group data in an Excel sheet. For example, using the spreadsheet below - I'm trying to automatically group records where the name and email address are identical. The goal is to send an email once to each person containing details of the invoice(s). In this case, Barry will receive one email which lists both invoices 2 and 4.

I'm wondering if anyone knows the best way to achieve this functionality? Thanks.

 

KT_3_0-1631081727829.png

 

I have the same question (0)
  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Sort by e-mail (column B)

    Get last row to %LoopMax% #then run this loop

    Loop with LoopIndex starting at (row) 2 until %LoopMax%, increment of 1)

        Read from Excel (Column B & Row %LoopIndex% to %ThisEmail%

        Read from Excel (Column B & Row %LoopIndex + 1% to %NextEmail%

        If %NextEmail%  = %ThisEmail%

            Read from Excel (Column C & Row %LoopIndex%) # then convert the number to %FileName%

            Add %FileName% to list %FilesToAttach%

            Next Loop

       Else

            Read from Excel (Column C & Row %LoopIndex%) # then convert the number to %FileName%

            Add %FileName% to list %FilesToAttach%

            Send e-mail with list of files as attachments

        EndIF

    End Loop

     

    In plain English, this says, if the next email is the same as this email, don't send an e-mail (yet), just add that file to the list of files to attach.  When this is the last of that specific e-mail, add the last file to the files to attach, then send the email with the attachments.

     

    Best of Luck!

  • KT_3 Profile Picture
    2 on at

    Thanks @MichaelAnnis! I'll give this a try 🙂 

  • AkshaySolanki Profile Picture
    128 on at

    Can you eloborate this with some screenshots if possible?
    I am not able to grasp and I have exact same criteria. 

     

    Thanks

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    VBScript Code: 

     

    Set objExcel=CreateObject("Excel.Application")
    Set objWbk=objExcel.Workbooks.open("D:\Sample Files\SampleEmailFile.xlsx")
    Set objWksht=objWbk.Worksheets(1)
    objExcel.Visible=true

    objWksht.UsedRange.AutoFilter 2,"%CurrentItem2%"
    LRow=objWksht.Cells(objWksht.Rows.Count,"A").End("-4162").Row
    FRow=objWksht.UsedRange.Offset(1).SpecialCells(12).Row

     

    if FRow=LRow Then
    objWksht.Range("C"&FRow).Copy
    Else
    objWksht.Range("C"&FRow&":C"&LRow).SpecialCells(12).Copy
    End If

    objExcel.DisplayAlerts=False
    objWbk.Close
    objWbk.Quit

     

    InzmamUl_0-1676794466747.png

    InzmamUl_2-1676794667453.pngInzmamUl_3-1676794691832.png

     

     

    Try to use this logic....this can help you achieve what you want

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 250 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 180

#3
Haque Profile Picture

Haque 159

Last 30 days Overall leaderboard