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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EXCEL - Text to Column: Row Format Problem

Status
Not open for further replies.

taz75

Programmer
Apr 17, 2001
15
GB
I have read several threads explaining how to format columns when using Text to Columns in Excel. I however have a variation on this problem....

I need to force the first row of my csv file to be Text in Excel. So that when I have ranges such as 05-10 it doesn't reformat this as a date. But not the subsequent ones as we need this to be numeric.

I have tried to format the row prior to "Text to Columns" - but this doesn't work.
I have also tried to import the whole things as text and then reformat the cells as Number - but to no avail.

Thanks to all!
Laura


 
You can go several ways on this. If I understand correctly, you first read a text file into Excel, and then apply the TextToColumns method? In this case, just apply the method twice, once to the first row, then to the rest, with different settings. If that's not how you are doing things, probably the easiest thing is to read it in as numbers, and then programmatically go through the first row and convert the "dates" back to the original text, such as in:

activecell = month(activecell) & "-" & day(activecell)

Rob
 
Thanks Rob,

I didn't think of doing it twice - I knew I must be missing something!
I can sleep easy at night now.
Laura
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top