B
Ben
I'm attempting to import data from an Excel 2002 spreadsheet into Access
2002 (using VBA and an Access form). There are a few columns within the
spreadsheet that could contain no data, a single number or a series of
numbers seperated by a comma. I have written a function to split this data
as appropriate that works OK when the Excel cell data has an ' at the start
(i.e. setting the cell data to text). The problem is that the ' will be not
neccessarily be there during real use.
My plan is to run a function that updates the Excel spreadsheet before
importing, something along the lines of,
MsgBox VarType(xlRS.Fields("F17"))
If Not Len(Nz(xlRS.Fields("F17"), "")) = 0 Then
xlRS.Fields("F17") = "'" & Nz(xlRS.Fields("F17"), "")
End If
The Excel datatype of the cells is 'General', but the VarType function
reports Double as the data type. This means that when I try to update the
cell contents I receive a Type Mismatch error. Is there anyway to
change/update the data type Excel will expect so I can update the cell
contents? If not any suggestions on a better way to import the data?
Thanks,
Ben
2002 (using VBA and an Access form). There are a few columns within the
spreadsheet that could contain no data, a single number or a series of
numbers seperated by a comma. I have written a function to split this data
as appropriate that works OK when the Excel cell data has an ' at the start
(i.e. setting the cell data to text). The problem is that the ' will be not
neccessarily be there during real use.
My plan is to run a function that updates the Excel spreadsheet before
importing, something along the lines of,
MsgBox VarType(xlRS.Fields("F17"))
If Not Len(Nz(xlRS.Fields("F17"), "")) = 0 Then
xlRS.Fields("F17") = "'" & Nz(xlRS.Fields("F17"), "")
End If
The Excel datatype of the cells is 'General', but the VarType function
reports Double as the data type. This means that when I try to update the
cell contents I receive a Type Mismatch error. Is there anyway to
change/update the data type Excel will expect so I can update the cell
contents? If not any suggestions on a better way to import the data?
Thanks,
Ben