Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Excel Data Import Question

Hell All -

I am importing data from the web. On the web the data is a phone
number: 4-3231

When it gets to Excel, Excel says "Aha! A date, no doubt!" and turns it
into 4/1/3231 and displays Apr-31, with a new custom mmm-yy format.

Is there a VBA way to turn off this Excel magic and leave April 1, 3231
as the string it used to be: 4-3231?

I tried to pre-format the cell as "General" in which case Excel turns it
into the serial date 486230. No help.

The best I've come up with so far is to test

If IsDate(GetPhone) Then GetPhone = "'" & Month(GetPhone) & "-" &
Year(GetPhone)

adding a single quote at the start to coerce a string. My sense is that
there is a more elegant way.

Can anyone chime in?


Thanks in advance.
....best, Capt N.

--
Email to (yes, you can so figure it out) ;-]

Scream and shout and jump for joy! I was here before Kilroy!

Sorry to spoil your little joke. I was here but my computer broke. ---Kilroy
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Excel Data Import Question

In article ,
Gord Dibben <gorddibbATshawDOTca wrote:

If you're importing using a Web Query you can set it under Options to not
turn those into dates.

Web Query dialogOptionsDisable date recognition.


Gord Dibben MS Excel MVP



Hi Gord -

Thank you for the insight. I never noticed it in the recorded settings
before you mentioned it. I made the appropriate correction in the Web
query VBA. Turns out that was only the first half of the problem
however.

The worksheet that was storing all the retrieved phone numbers also saw
it as a date after I took out the ISDATE() test.

To fix that, I preset its .numberformat to "@"

Now the strings stay strings, and it feels a little cleaner.

Thanks. Is there a way to turn on and off this "clairvoyance" (probably
has an official MS name) in VBA or otherwise?

....best, Capt N.

--
Email to (yes, you can so figure it out) ;-]

Scream and shout and jump for joy! I was here before Kilroy!

Sorry to spoil your little joke. I was here but my computer broke. ---Kilroy
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Import Question Steve Haack Excel Discussion (Misc queries) 2 May 20th 09 10:37 PM
Excel 2007 Import data question Stevens Setting up and Configuration of Excel 0 December 11th 07 09:22 PM
data import question dr chuck Excel Programming 3 June 19th 06 03:31 PM
Data import/extraction question tempacc Excel Programming 1 June 18th 05 07:29 AM
import external data via macro/vba question Drabbacs Excel Programming 1 May 24th 04 11:36 PM


All times are GMT +1. The time now is 10:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"