ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro output as Text (https://www.excelbanter.com/excel-programming/417549-macro-output-text.html)

steph44haf

Macro output as Text
 
I used the following Macro to list my tab names (which are dates):

Sub ListOfTabs()
For i = 1 To Sheets.Count
Cells(i, "f") = Sheets(i).Name
Next i
End Sub

But it listed the tab names as dates instead of text. Example: Tab Name =
09-01-08, but after macro runs output is 09/01/2008. How can I change the
Macro to get the proper output?

Any help is appreciated. Thanks!

Barb Reinhardt

Macro output as Text
 
One way

For i = 1 To Sheets.Count
Cells(i, "f") = "'" & Sheets(i).Name
Next i

--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"steph44haf" wrote:

I used the following Macro to list my tab names (which are dates):

Sub ListOfTabs()
For i = 1 To Sheets.Count
Cells(i, "f") = Sheets(i).Name
Next i
End Sub

But it listed the tab names as dates instead of text. Example: Tab Name =
09-01-08, but after macro runs output is 09/01/2008. How can I change the
Macro to get the proper output?

Any help is appreciated. Thanks!


steph44haf

Macro output as Text
 
Great - thanks!

"Barb Reinhardt" wrote:

One way

For i = 1 To Sheets.Count
Cells(i, "f") = "'" & Sheets(i).Name
Next i

--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"steph44haf" wrote:

I used the following Macro to list my tab names (which are dates):

Sub ListOfTabs()
For i = 1 To Sheets.Count
Cells(i, "f") = Sheets(i).Name
Next i
End Sub

But it listed the tab names as dates instead of text. Example: Tab Name =
09-01-08, but after macro runs output is 09/01/2008. How can I change the
Macro to get the proper output?

Any help is appreciated. Thanks!



All times are GMT +1. The time now is 12:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com