Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Power Automate Desktop
Answered

Expected: end of statement error in EXCEL MACRO

Like (0) ShareShare
ReportReport
Posted on 6 Mar 2022 10:42:49 by 45

Rampage_0-1646563229593.png

this is my MACRO CODE

 

Sub PrintDate(from As String)
 Sheets("Date").Select
 Range("A1").Select
 ActiveCell.Formula2R1C1 = "=SEQUENCE(7,1,"from")"
End Sub

 

Rampage_1-1646563325956.png

I am trying to passing this date into this code but its not working properly

  • Verified answer
    VJR Profile Picture
    7,635 on 07 Mar 2022 at 06:19:00
    Re: Expected: end of statement error in EXCEL MACRO

     

    You can add below if you would like to format the date column:

     

     

    Sub PrintDate(from As String)
    Dim lastrow As Integer

    Sheets("Date").Select
    Range("A1").Select
    ActiveCell.Formula2R1C1 = "=SEQUENCE(7,1," & """" & from & """" & ")"

    lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    Range("A1:A" & lastrow).NumberFormat = "m/d/yyyy"
    Range("A1").Select

    End Sub

     

     

  • VJR Profile Picture
    7,635 on 07 Mar 2022 at 03:15:44
    Re: Expected: end of statement error in EXCEL MACRO

     

    Working when you change the macro line to

     

    ActiveCell.Formula2R1C1 = "=SEQUENCE(7,1," & """" & from & """" & ")"

     

    VJR_0-1646622849259.png

     

  • VJR Profile Picture
    7,635 on 07 Mar 2022 at 02:51:49
    Re: Expected: end of statement error in EXCEL MACRO

    Hi @Rampage 

     

    That means the formula is incorrect.

     

    So, at first correct the formula in Excel and only then call it from PAD in order for it to work.

     

    What are you trying to achieve with the formula?

     

    Please provide as much details as possible.

     

  • Rampage Profile Picture
    45 on 06 Mar 2022 at 11:02:37
    Re: Expected: end of statement error in EXCEL MACRO

    Yeah i try with this.....

    Rampage_0-1646564522600.png

    giving input like this,

     

    Rampage_1-1646564542612.png

     

    not getting expected output

  • VJR Profile Picture
    7,635 on 06 Mar 2022 at 10:58:07
    Re: Expected: end of statement error in EXCEL MACRO

    Clearly the string parameter is showing up the error in the macro

     

    VJR_0-1646564132590.png

     

     

    Change the line as below after removing the quotes-

     

    ActiveCell.Formula2R1C1 = "=SEQUENCE(7,1,from)"

     

    After doing this, fix the macro first in the Excel and only then call from PAD.

     

    See how the Sequence formula function is used

    How to use the Excel SEQUENCE function | Exceljet

     

     

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Automate - Power Automate Desktop

#1
eetuRobo Profile Picture

eetuRobo 119 Super User 2025 Season 1

#2
CU12050101-0 Profile Picture

CU12050101-0 26

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 20 Super User 2025 Season 1

Overall leaderboard
Loading started