ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   zero's in excel cell getting rounded off (https://www.excelbanter.com/excel-programming/319219-zeros-excel-cell-getting-rounded-off.html)

Nasreen naqvi

zero's in excel cell getting rounded off
 


i am using a VB routine to parse the text file and copy the data to an
excel sheet.and if in text file the data is 000000000 it is getting
rounded to just one 0 and i need all of them in excel, any thoughts?

Private Sub cmdgo_Click()
Set sap_xlapp = CreateObject("Excel.Application") 'New
Excel.Application
sap_xlapp.DisplayAlerts = False
sap_xlapp.Workbooks.Open App.Path & "\SAP_Data.xls", , False, , , ,
True, , , True, False 'the excel file is now opened
sap_xlapp.Worksheets(1).Activate ' the excel worksheet is now active
for reading
Set sap_xlws = sap_xlapp.ActiveSheet
l_int_srow = 1

sap_xlws.Cells(l_int_srow, 1) = "Permanent Number"
sap_xlws.Cells(l_int_srow, 2) = "Name"
l_int_srow = l_int_srow + 1
cmdgo.Enabled = False
Call Main

'Transformation completed so clean up resources
cmdgo.Enabled = True
Set sap_xlws = Nothing
sap_xlapp.ActiveWorkbook.Save
sap_xlapp.ActiveWorkbook.Close
sap_xlapp.Quit
Set sap_xlapp = Nothing

End Sub

as seen in the code the numberic value is getting off which is stored in
variable of string type

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tom Ogilvy

zero's in excel cell getting rounded off
 
There is nothing in the code you show that would do this. There is nothing
in the code you show that would be considered as parsing a text file.

--
Regards,
Tom Ogilvy

"Nasreen naqvi" wrote in message
...


i am using a VB routine to parse the text file and copy the data to an
excel sheet.and if in text file the data is 000000000 it is getting
rounded to just one 0 and i need all of them in excel, any thoughts?

Private Sub cmdgo_Click()
Set sap_xlapp = CreateObject("Excel.Application") 'New
Excel.Application
sap_xlapp.DisplayAlerts = False
sap_xlapp.Workbooks.Open App.Path & "\SAP_Data.xls", , False, , , ,
True, , , True, False 'the excel file is now opened
sap_xlapp.Worksheets(1).Activate ' the excel worksheet is now active
for reading
Set sap_xlws = sap_xlapp.ActiveSheet
l_int_srow = 1

sap_xlws.Cells(l_int_srow, 1) = "Permanent Number"
sap_xlws.Cells(l_int_srow, 2) = "Name"
l_int_srow = l_int_srow + 1
cmdgo.Enabled = False
Call Main

'Transformation completed so clean up resources
cmdgo.Enabled = True
Set sap_xlws = Nothing
sap_xlapp.ActiveWorkbook.Save
sap_xlapp.ActiveWorkbook.Close
sap_xlapp.Quit
Set sap_xlapp = Nothing

End Sub

as seen in the code the numberic value is getting off which is stored in
variable of string type

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Jim Thomlinson[_3_]

zero's in excel cell getting rounded off
 
Reset the number format for the required range to display

"Range".NumberFormat = "000000"

"Nasreen naqvi" wrote:



i am using a VB routine to parse the text file and copy the data to an
excel sheet.and if in text file the data is 000000000 it is getting
rounded to just one 0 and i need all of them in excel, any thoughts?

Private Sub cmdgo_Click()
Set sap_xlapp = CreateObject("Excel.Application") 'New
Excel.Application
sap_xlapp.DisplayAlerts = False
sap_xlapp.Workbooks.Open App.Path & "\SAP_Data.xls", , False, , , ,
True, , , True, False 'the excel file is now opened
sap_xlapp.Worksheets(1).Activate ' the excel worksheet is now active
for reading
Set sap_xlws = sap_xlapp.ActiveSheet
l_int_srow = 1

sap_xlws.Cells(l_int_srow, 1) = "Permanent Number"
sap_xlws.Cells(l_int_srow, 2) = "Name"
l_int_srow = l_int_srow + 1
cmdgo.Enabled = False
Call Main

'Transformation completed so clean up resources
cmdgo.Enabled = True
Set sap_xlws = Nothing
sap_xlapp.ActiveWorkbook.Save
sap_xlapp.ActiveWorkbook.Close
sap_xlapp.Quit
Set sap_xlapp = Nothing

End Sub

as seen in the code the numberic value is getting off which is stored in
variable of string type

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



All times are GMT +1. The time now is 01:58 AM.

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