How can i specify a Format in a Excel Column

I have a function in VB 6 which opens Microsoft Excel and exports the data of
a Query into the worksheet. All works fine but the problem is that i have a field
which i populate with some credit card nbrs and the shhet displays them as a
5.47464E+15 instead of 5474643171576970

so my question, how can i set the format of a specific cell as well as how can i set this
for a specific column


AlexPonnathAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RogueSolutionsCommented:
If you want Excel to ignore the number characteristic of the Credit Card Number put an apostrophe (') on the front of it as you pass it to the worksheet.  Excel then handles it as text

So

xlSheet.Cells(1,1).Value = "'" & strCreditCardNumber
0
RogueSolutionsCommented:

Sorry, to answer your question, it's not really a formatting issue.  The 'number' has no useful meaning, better to handle it as a string.

The apostrophe doesn't show in Excel by the way.
0
EDDYKTCommented:
' set b5

Application.Cells(5, 2).NumberFormat = "################"
Application.Cells(5, 2).Value = "5474643171576970
"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RogueSolutionsCommented:

Actually, following on from Eddy's comment, I think you'd be better to go with ...

Application.Columns("B:B").NumberFormat = "0000000000000000"

A Credit Card number is always 16 digits (at least here in the UK) so you wouldn't want to lose any proceeding zeros, although I doubt any numbers start like that (at the moment!)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.