In Excel, highlight the column and change its type to Text (Ctrl+1). Change
the value in the first value cell to someting with a text character. Go back
to Access and re-link the table. Access should now set the field to a Text
type. You can now go back to Excel and restore the value that you changed.
Barry
"Mominator" wrote:
> Help.... I have an excel sheet I want to link to...but when I do, i get the
> #NUM error
> on over half of the records....(ones which have both a number and a letter
> in the cell) but when I import the same excel worksheet, everything is
> fine....
> how can I link but not have the error?
> any help is greatly appreciated!
Barry
Open the Excel macro editor (ALT + F11)
Create a new module by right-clicking the module node in the Project
Explorer (CTRL+R if it's not visible) and selecting Insert Module
Paste the following code into the new module:
Public Sub FormatAsText()
Dim cell As Object
For Each cell In Selection
cell.Value = " " & cell.Value
cell.Value = Right(cell.Value, Len(cell.Value) - 1)
Next
End Sub
Back in your Excel workbook, you can run this macro by selecting the cells
you want to fix (a whole column?) and selecting Tools, Macro, Macros
(ALT+F8). Find the FormatAsText macro you just created, highight it, and
click run.
Go back to Access and re-link the table.
Kind of a long way around, but it's necessary if you have a mixture of
formats within a column.
Barry
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.