Question : Excel Numbers imported as dates into memo field

I linked to an Excel spreadsheet. I then appended (using VBA to run an SQL statement) one of the spreadsheet columns into a memo field in an empty Access table. In this particular spreadsheet, 70% of the values in the column are in a Date format, 15% are in a Currency format, and 15% are integers in a General format.

When I append the spreadsheet column, the currency and integer values get converted to dates before being written to the memo field in Access. I do not want this. That is, I want the values in the Access memo field to look the same as they do in Excel. I want dates to look like dates and numbers to look like numbers (and text t look like text).

By the way, if I open the linked spreadsheet in Access, it displays the integers and currency values as dates.

I am using Office 2003 sp3.

How can I prevent the imported Excel numbers from turning into dates in my Accessmemo field?

Answer : Excel Numbers imported as dates into memo field

You need to transform your Excel data to text before linking / importing. The macro below will do that on the current selection: select the column and run.

If you need help implementing this solution, please read the article http:/A_1920.html which was written specifically for cases like this.

Good luck!
(°v°)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
Sub MakeText()
    
    Dim rngSel As Range
    Dim rngC As Range
    Dim strText As String
    
    ' Validate current selection
    If TypeName(Selection) <> "Range" Then Exit Sub
    Set rngSel = Intersect(Selection, Selection.Worksheet.UsedRange)
    If rngSel Is Nothing Then Exit Sub
    
    ' Converts all cells in the selection to text
    For Each rngC In rngSel
        strText = rngC.Text
        rngC.NumberFormat = "@"
        rngC.Value = strText
    Next rngC
    
End Sub
Random Solutions  
 
programming4us programming4us