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

pipe delimited 2

Status
Not open for further replies.

dodge20

MIS
Jan 15, 2003
1,048
US
Is it possible to save an excel worksheet with | as the delimiter? Dodge20
If it ain't broke, don't fix it.
 
I am having a problem with a 0 in front a a number. I have account numbers, and some of them start with a zero. Excel Automatically removes those zeros. I change the format of the cells, so it allows the correct number of zero's, but when I run this macro, they are gone. Any ideas?

Dodge20
If it ain't broke, don't fix it.
 
Nope, didn't work Dodge20
If it ain't broke, don't fix it.
 
Use the same numberformat string that you specified for the cells in the spreadsheet in the print# statement, e.g.

print#1, format(activesheet.cells(r,c),"0000000"); "|";
Rob
[flowerface]
 
Won't that change every column? I just want column F, if there is a way to do that. Dodge20
 
Code:
for c=1 to .column+.columns.count-2
          select case c
          case 6
          print#1, format(activesheet.cells(r,c),"0000000"); "|";
          case else
          print#1, format(activesheet.cells(r,c)); "|";
      next c

One thing I don't understand is why Rob is using
Code:
for c=1 to .column+.columns.count-2
- it's perfectly good code, but it's be easier to follow if he used
Code:
for c = 1 to .columns.count -1
since by starting the loop at column C = 1, he's assuming that the first cell to be written to file in each row appears in column "A".

he's assumed all your data starts in column "A", but if you look at the exterior loop he's not assumed that your data starts in row 1 - I can't see why - maybe I've missed something?

Also, just out of interest, how many rows do you have, or are likely to have? If you have more than 32,000 the macro will fall over because integers can't handle numbers much bigger than that. I can't tell from your post whether you're likely to have this many rows or not.
 
aw sugar, just before the "next" you need to insert a line saying "end select".

D'oh!
 
I think the c=1 to .column+.columns.count-2 allows blank columns to precede any data. I need column A to be blank, and this allow me to do so. Dodge20
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top