I would like to write to a text file from Excel, but the data order is different from the column order in Excel. For Example:
Excel Column : Col1, Col2, Col3, Col4, Col5 Text file : Col1, Col2, Col5, Col4, Col3
Please help me to solve this problem.
Simple: make a copy of the current sheet and change the column order within the copy before saving. When you don't need the copy then any more, delete it.
You could even make a macro to resort the second sheet #
(adsy2010, you now have enough rep to comment, please re-submit it as one and I will delete this placeholder).
Thank you for answer.
I developed the following way of doing it:
Code:
For i = 1 To LastRow
For j = 2 To 10
Select Case j
Case 3
strCellValue = Trim(shSheetName.Cells(i, j + 2).Value)
Case 5
strCellValue = Trim(shSheetName.Cells(i, j - 2).Value)
Case Else
strCellValue = Trim(shSheetName.Cells(i, j).Value)
End Select
Next j
'Process of Write [strCellValue] to text file
Next i