views:

90

answers:

2

Hi,

When I use WinSQL to run a SQL statement, the result is 20100803000001812. However, when I incorporate the SQL as a macro, the result is 2.01008E+16. What should I do in the macro in order to maintain the result as 20100803000001812 ?

Thanks,

Bob

A: 

According to this article ActiveCell.NumberFormat = "@" should do the trick.

BenV
Bob
As suggested by Tahbaza on 4 Oct 2010, an apostrophe if you're just wanting the column to display as text, something like :- select Cno,Itno,CONCAT('''',Ref) as Ref from test.
Bob
A: 

ActiveCell.NumberFormat = "0" works for me (not what I expected, but so it goes)

You might want to throw in a Cells.Columns.AutoFit to resize the columns as necessary.

variant
Nope, it's still shows as 2.01008E+16.
Bob
@Bob - Where are you putting this code in? What if you try setting the number format manually?
variant
Bob
@Bob good that you got it figured out. You should post the solution and accept that as your answer to close out the question.
variant