Created
May 26, 2014 04:42
-
-
Save stormxuwz/93b8b53f8ed25ddcac2f to your computer and use it in GitHub Desktop.
Parse Triaxus Excel File into CSV file with Excel VBA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub outputfile_whole() | |
Dim Infilename, outfilename As String | |
Dim name As String | |
Filename = ThisWorkbook.FullName | |
filename1 = ThisWorkbook.name | |
filename1 = Left(filename1, Len(filename1) - 5) | |
outfilename = Left(Filename, Len(Filename) - 5) & "new.csv" | |
outfilename1 = Left(Filename, Len(Filename) - 5) & "new_XY.csv" | |
a = "" | |
b = "" | |
c = "" | |
name = "" | |
Open outfilename For Output As #1 | |
Open outfilename1 For Output As #2 | |
Print #2, filename1, Cells(60, 3) | |
Row = 59 | |
For i = 3 To 9 | |
a = a & Cells(Row, i) & "," | |
Next | |
For i = 20 To 20 | |
a = a & Cells(Row, i) & "," | |
Next | |
For i = 25 To 35 | |
a = a & Cells(Row, i) & "," | |
Next | |
For i = 41 To 52 | |
a = a & Cells(Row, i) & "," | |
Next | |
For i = 53 To 61 | |
a = a & Cells(Row, i) & "," | |
Next | |
For i = 62 To 66 | |
a = a & Cells(Row, i) & "," | |
Next | |
For i = 67 To 68 | |
a = a & Cells(Row - 1, i) & "," | |
Next | |
For i = 69 To 72 | |
a = a & Cells(Row, i) & "," | |
Next | |
For i = 74 To 81 | |
a = a & Cells(Row - 1, i) & "," | |
Next | |
For i = 82 To 202 | |
a = a & Cells(Row - 4, i) & "um," | |
Next | |
a = a & Cells(Row - 4, 203) & "um" | |
Print #1, a | |
a = "" | |
For Row = 60 To 100000 | |
If Cells(Row + 1, 1) = "" Then | |
Exit For | |
End If | |
For i = 3 To 9 | |
a = a & Cells(Row, i) & "," | |
Next | |
For i = 20 To 20 | |
a = a & Cells(Row, i) & "," | |
Next | |
For i = 25 To 35 | |
a = a & Cells(Row, i) & "," | |
Next | |
For i = 41 To 52 | |
a = a & Cells(Row, i) & "," | |
Next | |
For i = 53 To 61 | |
a = a & Cells(Row, i) & "," | |
Next | |
For i = 62 To 72 | |
a = a & Cells(Row, i) & "," | |
Next | |
For i = 74 To 202 | |
a = a & Cells(Row, i) & "," | |
Next | |
a = a & Cells(Row, 203) | |
Print #1, a | |
a = "" | |
b = "" | |
c = "" | |
If (Row >= 60) Then | |
If Cells(Row, 5) <> Cells(Row + 1, 5) Then | |
Print #2, Cells(Row, 5) & "," & Cells(Row, 7) & "," & 0 | |
End If | |
End If | |
Next | |
Close #1 | |
Close #2 | |
End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment