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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Expected: end of state...
Power Automate
Answered

Expected: end of statement error in EXCEL MACRO

(0) ShareShare
ReportReport
Posted on 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

I have the same question (0)
  • VJR Profile Picture
    7,635 on at

    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

     

     

  • Rampage Profile Picture
    45 on at

    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 at

    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.

     

  • VJR Profile Picture
    7,635 on at

     

    Working when you change the macro line to

     

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

     

    VJR_0-1646622849259.png

     

  • Verified answer
    VJR Profile Picture
    7,635 on at

     

    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

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard