View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave O Dave O is offline
external usenet poster
 
Posts: 427
Default Want to format data

Is this an Excel question or an SQL question? Your post says you have
the data in Excel and that SQL is dropping the lead apostrophe and
leading zeros. I know nothing about SQL, but can you declare the
variable in SQL as text so it will read those values as text?

As a workaround, if you write a VBA script that writes the data out of
Excel and into a text file, can you import the text file into SQL? The
VBA would look like

sub WriteToTextFile()
dim OutputString as string

open "c:\abc.txt" for output as #1 'write to a file called abc.txt on
your C: drive

range("a1").select 'change this cell reference to the upper left
corner of your data

do until activecell.value = "" 'perform loop functions until encounter
a blank row
outputstring = activecell.value & activecell.offset(0,1).value
print #1, outputstring
outputstring = ""
activecell.offset(1,0).select
loop

close #1
end sub

Dave O
Eschew Obfuscation