Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

QueryTables.Add corrupt data because of data type

Status
Not open for further replies.

shaggz7even

Programmer
Nov 6, 2002
13
0
0
US
Im using the QueryTables.Add method to import data from a web site.

One of the records is an eighteen digit account number. When VBA retrieves the number, it gets it single precision number, which when formatted, turns the last 2 digits or so to zeros

Is there a property of the add method i need to set to retrieve the data as text?

This is what i got:

With Worksheets("Query").QueryTables.Add _
Connection:="URL;" & strURL, _
Destination:=Range("a1"))
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
'.PreserveColumnInfo = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.PreserveFormatting = True
End With

this
50020000120002344
looks like this
5.002E+16
which turns out like this
50020000120002300
which sucks

Any help would be appreciated
thanks
 
Have you tried to format [A1] as text before the Refresh ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
that was my first idead
formatting as text just shows its as 5.002E+16
 
And this ?
.WebFormatting = xlAll

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Nope, same thing

The msdn website says nothing about this
i can't find a single faq on what exactly each of these
properties do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top