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

Save each column into .text file

Status
Not open for further replies.

pukiamak

Technical User
Jul 14, 2006
44
US
Hello guys,

I have 10 columns in Sheet 1. How can I save each column into .text file so that I have total of 10 different .text file?

Thank you,
tony
 



Hi,

Insert a new sheet.

Loop thru each colunm, copy each to the NewSheet.[A1], save as text file.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
thanks for the reply. How can i count the filled column in my sheet? the reason is I do not have fixed amount of column everytime.

Thanks,
tony
 
Hi guys,

Does anyone know how to select particular column in Statistica using VB macros. I have 10 columns and I want select one column at a time, copy and paste into new Sheet.

Thx,
Tony
 
pukiamak,
No idea about Statistica but you can use the [tt]UsedRange[/tt] property in Excel to identify the number of rows and columns.
Code:
ActiveSheet.UsedRange.Rows.Count
ActiveSheet.UsedRange.Columns.Count

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 


Code:
with ActiveSheet.UsedRange
  for iCol = .column to .column + .columns.count - 1
    ...
  next
End With


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Hi guys,

I am back with more question :)
so now I have everything working but I have problem in saveas.

I wish to save the 1st column as "new1.txt"
2nd column as "new2.txt"
3rd column as "new3.txt" and so on

I can not figure out anyway to give different file name in the code since the filename is enclosed in " " which means evertime I run the macro I have to change the filename in the code.

Thank you guys,
Tony
 


Code:
with ActiveSheet.UsedRange
  for iCol = .column to .column + .columns.count - 1
    ...
      Activeworkbook.savaeas "New" & iCol & ".txt"
  next
End With

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Hello guys,

I am wondering is there any way to save 600 columns of Excel data into one text file without disrupting the column format?

Thank you,
Tony
 


Hi,

[red]600[/red] columns???

Really???

"...without disrupting the column format..."

If you must disrupt the column format in order to AutoFit and SaveAs, first macro record the current setup in order to restore the format.


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top