Excel rename sheet name + hh:mm

Hi all!

I use “Sheet1_”+DateTime.Now.ToString(“dd-MM-yyyy”) and works fine to rename a sheet

image

but i want do add hh:mm to the sheet name…something like that:

“Sheet1_”+DateTime.Now.ToString(“dd-MM-yyyy hh:mm:ss”) but i always get erros.

Any ideas? :slight_smile:

Hello @Pedro_Santos,

I think colons are not allowed in sheet names.

2 Likes

Hey @Pedro_Santos :wave:

@jcastro is right, colons are not allowed in sheet names so, you can achieve your output using the code below:

"Sheet1_" + Now.Day.ToString + "-" + Now.Month.ToString + "-" + Now.Year.ToString + "-" + Now.Hour.ToString + "-" + Now.Minute.ToString + "-" + Now.Second.ToString
3 Likes

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