ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Converting a file to text (https://www.excelbanter.com/excel-programming/406407-converting-file-text.html)

jhong

Converting a file to text
 
Hi Everyone,


I've got this very useful code from this forum, im running this code
to my excel file that has plenty of sheets with cost centers as sheet
names. My problem is each cost center starts with zero like 011888
when i run this code the macro will only get 11888 without the zero,
can you help me edit this code so it an get all the code as it is.
Thanks in advance!!

Dim NewSheet As Variant

Dim i As Integer


Set NewSheet = Sheets.Add(Type:=xlWorksheet)
For i = 1 To Sheets.Count
NewSheet.Cells(i, 1).Value = Sheets(i).Name
Next i

[email protected]

Converting a file to text
 
On Feb 20, 9:36*pm, jhong wrote:
Hi Everyone,

I've got this very useful code from this forum, im running this code
to my excel file that has plenty of sheets with cost centers as sheet
names. My problem is each cost center starts with zero like 011888
when i run this code the macro will only get 11888 without the zero,
can you help me edit this code so it an get all the code as it is.
Thanks in advance!!

Dim NewSheet As Variant

Dim i As Integer

Set NewSheet = Sheets.Add(Type:=xlWorksheet)
For i = 1 To Sheets.Count
* * NewSheet.Cells(i, 1).Value = Sheets(i).Name
Next i


Try this
Dim NewSheet As Variant
Dim i As Integer
Set NewSheet = Sheets.Add(Type:=xlWorksheet)
For i = 1 To Sheets.Count
NewSheet.Cells(i, 1).NumberFormat = "@"
NewSheet.Cells(i, 1).Value = Sheets(i).Name
Next i



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

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