|
-
Jan 24th, 2010, 02:38 PM
#1
Thread Starter
Junior Member
Exel cell
Once again i find myself in need of help.
Exel has the habbit to 'change' cells if they have a number of numbers.
The number added into the cell changes to like 1.025EEE.
Does not happen if you add letters instead of numbers
Dim oXLApp As Excel.Application 'Declare the object variables
Dim oXLBook As Excel.Workbook
Set oXLApp = New Excel.Application 'Create a new instance of Excel
Set oXLBook = oXLApp.Workbooks.Add 'Add a new workbook
oXLApp.Visible = True 'Show it to the user
Set oXLBook = oXLApp.Workbooks.Add 'Add a new workbook
Set oXLApp = Nothing
Set oXLSheet = oXLBook.Worksheets(1) 'Work with the first worksheet ??????????????????????? NODIG OF NIET
Open "ONTKEN" For Random As #5 Len = Len(NOTmE)
bestandlengte = LOF(5) / 177
Get 5, bestandlengte, NOTmE
For I = 1 To bestandlengte
Get 5, I, NOTmE
oXLSheet.Cells(I, 1).Value = Trim(NOTmE.dDAG) ' dagnummer invullen''' 1 omlaag 1 rechts
oXLSheet.Cells(I, 2).Value = Trim(NOTmE.dDATUM) 'datum invullen
oXLSheet.Cells(I, 3).Value = Trim(NOTmE.dDOSSIER) 'dossier invullen
oXLSheet.Cells(I, 4).Value = Trim(NOTmE.dZMAAND) 'maand invullen
oXLSheet.Cells(I, 5).Value = Trim(NOTmE.dZJAAR) 'jaar invullen
oXLSheet.Cells(I, 6).Value = Trim(NOTmE.dZTIJD) 'tijd invullen
oXLSheet.Cells(I, 7).Value = Trim(NOTmE.dAWB) ' 12 digit number waybilnummer invullen <<<<<<< this one goes wrong
oXLSheet.Cells(I, 8).Value = Trim(NOTmE.dcOMBO1) 'naam invullen
I = I + 1
Next
Set oXLBook = Nothing 'Disconnect from Excel (let the user take over)
Set oXLApp = Nothing
I tried changing .Value = into .Text but that dont help
How do i get exel to accept this 12 digit number without 'changing it' ??????
-
Jan 24th, 2010, 03:19 PM
#2
Re: Exel cell
There are two main ways, one is to tell Excel to display it in the way you want (manually it is via "Format Cells", code is .NumberFormat), the other is to force it to be text by adding the ' character in front of the value:
Code:
oXLSheet.Cells(I, 7).Value = "'" & Trim(NOTmE.dAWB)
-
Jan 24th, 2010, 05:46 PM
#3
Re: Exel cell
If you want to convert number to text then do what si_the_geek mentioned, otherwise:
* When cell format is General (default with new created worksheet), with large number (12 digits in this case), if column width is not wide enough, Excel will display the number in scientific notation such as 1.025E11.
* If set .NumberFormat of the cell to "0" and column width is also not wide enough, the number will display as ########.
* Set the width of column G larger, the number will be displayed in full of 12 digits.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|