PC Review


Reply
Thread Tools Rate Thread

Data type conversion from Excel

 
 
Jon
Guest
Posts: n/a
 
      17th Aug 2005
I am trying to import an Excel spreadsheet. The fields in the
spreadsheet include a 6-digit code, some with leading zeros. These
cells are formatted as text. In the Access import wizard, the data type
in the field options is grayed out and it is importing the field as a
double. Is there any way to control the format on the import?


Jon Cosby

 
Reply With Quote
 
 
 
 
tina
Guest
Posts: n/a
 
      17th Aug 2005
you could save the Excel file as a .txt file, then import the .txt file.
using the Access import wizard, you have almost complete control of how data
imports from a text file.

hth


"Jon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I am trying to import an Excel spreadsheet. The fields in the
> spreadsheet include a 6-digit code, some with leading zeros. These
> cells are formatted as text. In the Access import wizard, the data type
> in the field options is grayed out and it is importing the field as a
> double. Is there any way to control the format on the import?
>
>
> Jon Cosby
>



 
Reply With Quote
 
John Nurick
Guest
Posts: n/a
 
      17th Aug 2005
On 16 Aug 2005 17:48:06 -0700, "Jon" <(E-Mail Removed)> wrote:

>I am trying to import an Excel spreadsheet. The fields in the
>spreadsheet include a 6-digit code, some with leading zeros. These
>cells are formatted as text. In the Access import wizard, the data type
>in the field options is grayed out and it is importing the field as a
>double. Is there any way to control the format on the import?


If you prefix the values in the Excel cells with an apostrophe ', it
forces them to be treated as text. These Excel VBA functions may help:

Sub AddApostrophesNumericToSelection()
'adds apostrophes to numeric values only
Dim C As Excel.Range
For Each C In
Application.Selection.SpecialCells(xlCellTypeConstants).Cells
If IsNumeric(C.Formula) Then
C.Formula = "'" & C.Formula
End If
Next
End Sub

Sub AddApostrophesAllToSelection()
Dim C As Excel.Range
With ActiveWorkbook.ActiveSheet
For Each C In Intersect(Selection,
..UsedRange).SpecialCells(xlCellTypeConstants).Cells
C.Formula = "'" & C.Formula
Next
End With
End Sub

Sub AddApostrophesAllToColumn( _
ByVal TheColumn As Long _
)
Dim C As Excel.Range
With ActiveWorkbook.ActiveSheet
For Each C In Intersect(.Columns(TheColumn), _
.UsedRange).SpecialCells(xlCellTypeConstants).Cells
C.Formula = "'" & C.Formula
Next
End With
End Sub

Sub RemoveApostrophes()
Dim C As Excel.Range
For Each C In Application.Selection.Cells
C.Formula = C.Formula
Next
End Sub


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
 
Reply With Quote
 
Michael J. Strickland
Guest
Posts: n/a
 
      17th Aug 2005
Have you tried clicking on the "Advanced" button just before the
wizard finishes and setting the data type to text there?



--
---------------------------------------------------------------
Michael J. Strickland
Quality Services (E-Mail Removed)
703-560-7380
---------------------------------------------------------------
"Jon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am trying to import an Excel spreadsheet. The fields in the
> spreadsheet include a 6-digit code, some with leading zeros. These
> cells are formatted as text. In the Access import wizard, the data type
> in the field options is grayed out and it is importing the field as a
> double. Is there any way to control the format on the import?
>
>
> Jon Cosby
>



 
Reply With Quote
 
Jon
Guest
Posts: n/a
 
      17th Aug 2005
Thanks Tina, that worked.


Jon

Tina wrote:
> you could save the Excel file as a .txt file,
> then import the .txt file. using the Access
> import wizard, you have almost complete control
> of how data imports from a text file.


 
Reply With Quote
 
tina
Guest
Posts: n/a
 
      17th Aug 2005
you're welcome
it doesn't really solve the problem, like John's solution does; it just
sidesteps it. but it's what i usually do - i despise importing from Excel!
<g>


"Jon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks Tina, that worked.
>
>
> Jon
>
> Tina wrote:
> > you could save the Excel file as a .txt file,
> > then import the .txt file. using the Access
> > import wizard, you have almost complete control
> > of how data imports from a text file.

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. M. Bruil Microsoft Access 2 26th Mar 2009 08:30 AM
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. M. Bruil Microsoft Access 0 25th Mar 2009 08:10 PM
Data type Conversion from Excel inconsistency =?Utf-8?B?UmFjZXI0OQ==?= Microsoft Access Macros 2 3rd Oct 2007 11:56 PM
data type conversion when automating excel from access =?Utf-8?B?VGFueWE=?= Microsoft Access VBA Modules 5 1st Aug 2007 11:39 PM
Excel VBA - Data Type Conversion problem PaulC Microsoft Excel Programming 3 10th May 2004 04:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:29 AM.