mscallisto
Technical User
Ho do I shorten the the line of code that reads:
e.g. replace the 1 2 3 4 with a variable representing j=1 to usedcolumns ?
Code:
Print #1, .Cells(i, 1); "|"; .Cells(i, 2); "|"; .Cells(i, 3); "|"; .Cells(i, 4)
e.g. replace the 1 2 3 4 with a variable representing j=1 to usedcolumns ?
Code:
Sub pipey()
Dim usedrows, usedcolumns As Integer
Open "C:\Documents and Settings\sam\Desktop\Pipey.txt" For Output As #1
With Worksheets(1).Range("a:d")
usedrows = ActiveSheet.UsedRange.Rows.Count
usedcolumns = ActiveSheet.UsedRange.Columns.Count
For i = 1 To usedrows
Print #1, .Cells(i, 1); "|"; .Cells(i, 2); "|"; .Cells(i, 3); "|"; .Cells(i, 4)
Next i
End With
Close #1
MsgBox ("Done Successfully")
End Sub