Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need to keep text format when retrieving records from database
I'm importing records from an access database to excel using ADO. When the
records are stored in the excel sheet, the format has changed. How do I keep it to a text format. For example, record 9900000000000080 has changed from text to general and now looks like 9.9E+15. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need to keep text format when retrieving records from database
When I use ADO to extract from Access to xl I use the following code to
format several columns: The variable "ExtractFields" is the xl Named Range of Field Names ( at the top of each col of the extract range) Dim Field As ADODB.Field Dim k as interger k = 1 For Each Field In rs.Fields If Field.Type = adDate Then ExtractFields(k).EntireColumn.NumberFormat = "mm/dd/yy" ElseIf Field.Name Like "Age" Then ExtractFields(k).EntireColumn.NumberFormat = "00" ExtractFields(k).EntireColumn.HorizontalAlignment = xlCenter End If k = k + 1 Next Field You should be able to adapt the above to your situation, changing to whatever format you want for the desired field. Or just manually select the column and select FormatCellsNumber to change the format after extracting. "Markantesp" wrote: I'm importing records from an access database to excel using ADO. When the records are stored in the excel sheet, the format has changed. How do I keep it to a text format. For example, record 9900000000000080 has changed from text to general and now looks like 9.9E+15. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Records Database | Excel Discussion (Misc queries) | |||
Creating a Product DATABASE in ACCESS or EXCEL and then retrieving | Excel Discussion (Misc queries) | |||
Retrieving data from database (MS Sql Server) to Excel | Excel Discussion (Misc queries) | |||
Retrieving data from a database list | Excel Discussion (Misc queries) | |||
Adding New Records To Excel Database.. | Excel Programming |