Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am using the following code to export cell selection to a txt file. The
code works fine with the following problem. Instead of the output being a1,b1,c1 a2,b2,c2. I need the output to be a1,a2,b1,b2,c1,c2 etc. depending on number of columns selected. Here is code I am currently using. Sub Export2Textfile() Dim Textfile As Variant Dim LastRow As Long Dim XportArea As Range Dim Cel As Range Dim iFnum As Integer 'Select a textfile to save to Textfile = Application.GetSaveAsFilename( _ InitialFileName:="text.txt", _ FileFilter:="Text files, *.txt)", _ Title:="Save textfile as:") If Textfile = False Then Exit Sub On Error Resume Next 'Select the cells to export: Set XportArea = Application.InputBox( _ "Select the cells to export:", _ "Use your mouse:", Selection.Address, Type:=8) If XportArea Is Nothing Then Exit Sub 'open / create the textfile iFnum = FreeFile Open CStr(Textfile) For Output As iFnum 'loop cells For Each Cel In XportArea 'write to textfile Print #iFnum, Cel.Text Next Close #iFnum End Sub I am thinking I will need to add another loop. Any help would be greatly appreciated |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need help for getting output | Excel Discussion (Misc queries) | |||
Help on macro output | Excel Programming | |||
Output to CSV | Excel Programming | |||
Getting output from an excel output back to cscript.. | Excel Programming | |||
Too much output... PLEASE HELP! | Excel Programming |