Dynamic sheet name selection

Hi,

I need to design a solution which runs monthly and get that current year sheet and update data ,likewise when BOT runs next year it need to pick up sheet name with next year and write the data , can we pass dynamic year in the sheet name

eg- current year BOT need to use only Avg 2021
when BOT runs 2023 it should pic 2023 sheet

I did create a variable for year and passed it in sheet name it shows an error , is it not possible to do this way ?
image

image

And this currentyear1 variable’s datatype is ? @monishanair2010

If its integer

Use CurrentYear1.ToString

or Change currentyear1 datatype to string

Regards
Sudharsan

Hi,

Can you try to add .ToString as the following?

Excel.Sheet("Act"+CurrentYear1.ToString)

Regards

You can also use like now.year.ToString to get the current year (i.e., 2022)

Regards
Sudharsan

Hi @monishanair2010

You can pass like this :

Excel.Sheet("AVG"+CurrentYear.ToString).Cell("A1")

image

Regards
Gokul

Thanks everyone, I tried that but still I get this error , not sure what could be the possible reason
image

Thanks all , I tried I get this error , datatype I used is string
image

Share the screenshot of the activity @monishanair2010

Use .cell(“Your cell Value”) @monishanair2010

As i have already mention in my above post. Have check on the @monishanair2010

yes looks like that created the issue, using modern activities first time . Thank you

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.