Was bedeutet >>For colIndex
Dietmar
kann mir jemand diesen Code erklären? Es scheint ein AusleseCode zu sein, der das Sheet als Textdatei ausliest.
Ich will das zugrundeliegende Sheet neu gestalten.
Meine Frage:
Kann es sein dass der Code Daten ausliest, die farblich hinterlegt sind? Wenn ja, gescheit das nur in bestimmten Bereichen?
Ich möchte das Sheet nämlich auch farblich teilweise neu gestalten.
Sollte ich das dann lieber lassen?
Vielen Dank vorab!
Dietmar aus Aachen
Sub Button4_Click()
iFileNum = FreeFile 'get next free windows file handle
Set wsSheet = ActiveSheet
Dim lastTag As String
Dim lineText As String
Dim currSection As String
Dim outFileName As String
'Dim outFileCharDate As String
'outFileName = Cells(9, 2).Value
outFileName = Date
outFileName = Replace(outFileName, "/", "_")
'outFileCharDate = Cells(12, 2).Value
'outFileCharDate = Replace(outFileCharDate, "/", "_")
'Open "c:\" & outFileName & "_" & outFileCharDate & ".txt" For Append As #iFileNum ' _
create file in current directory, path can be fully qualified
Open "c:\" & outFileName & ".txt" For Append As #iFileNum
For RowIndex = 1 To 400 'for each row in the range
lineText = ""
For colIndex = 1 To 9 'loop through chosen cols in that column
'If Cells(RowIndex, colIndex).Value "" Then
Dim tmpString, tmpChar As String
tmpString = Cells(RowIndex, colIndex).Value 'grab the value of this cell
tmpChar = Left(tmpString, 1) 'grab first two characters
If (tmpChar = "[") Then
'Print #iFileNum, "" & tmpString & "" 'print tag
lineText = lineText & "" & tmpString & ""
currSection = Left(tmpString, InStr(tmpString, "]"))
lastTag = ""
ElseIf (tmpChar = "" & tmpString & ""
lineText = lineText & "" & tmpString & ""
lastTag = tmpString
ElseIf (tmpChar = "{") Then
'Print #iFileNum, "" & tmpString & ""
'lineText = lineText & "" & tmpString & ""
lastTag = ""
Else
If Cells(RowIndex, colIndex).Value "" Then
'Print #iFileNum, "" & Cells(RowIndex, colIndex).Value & "" _
_
'add text to file with a carriage return implicit
lineText = lineText & "" & Cells(RowIndex, colIndex).Value & ""
If (lastTag "") Then
lastTag = ""
End If
Else
If (currSection = "[A]") Or (currSection = "[D]") Or (currSection = "[C]") _
_
Or (currSection = "[E]") Or (currSection = "[G]") Or (currSection = "[F]") Then
'Print #iFileNum, "-"
lineText = lineText & "-"
lastTag = ""
End If
End If
End If
'End If
Next
Print #iFileNum, lineText
Next
Close #iFileNum 'close file handle
MsgBox "Data written to file " & "c:\" & outFileName & ".txt", vbOKOnly, "Completed"
End Sub