ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Creating Worksheet using Server Object (https://www.excelbanter.com/excel-worksheet-functions/26508-creating-worksheet-using-server-object.html)

Olivia Towery

Creating Worksheet using Server Object
 
I am using the CreateObject("Excel.Application") to create a workbook from
three separate tables in a sql db. This works great and compiles three
separate sheets to one workbook. My issue is that I need the cell
formatting to be text for all entries. However the Excel spreadsheet will
take my data - 05/05 and translate to 05-May OR my data 0140 and translate
to 140.

How can I write the vbscript to format all cells to text?

--
Olivia Towery



Miyahn

"Olivia Towery" wrote in message
I am using the CreateObject("Excel.Application") to create a workbook from
three separate tables in a sql db. This works great and compiles three
separate sheets to one workbook. My issue is that I need the cell
formatting to be text for all entries. However the Excel spreadsheet will
take my data - 05/05 and translate to 05-May OR my data 0140 and translate
to 140.

How can I write the vbscript to format all cells to text?


Like this.

With CreateObject("Excel.Application")
.Visible = True
With .Workbooks.Add(1).Sheets(1)
.Cells.NumberFormat = "@"
.Cells(1, 1).Formula ="05/05"
End With
End With

--
Miyahn (Masataka Miya****a) JPN
Microsoft MVP for Microsoft Office - Excel(Jan 2005 - Dec 2005)




All times are GMT +1. The time now is 07:06 AM.

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