Splitten von Zellinhalt per Parameter
04.07.2003 13:54:29
Splitten eines Namens per Parameter
Komische Sache! Wieso funktioniert dies:
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("a1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, Tab:=True, Other:=True, OtherChar _
:=TextBox1, FieldInfo:=Array(Array(1, 1), Array(2, 1))
ActiveWindow.ScrollRow = 5
Columns("B:B").Select
Selection.TextToColumns Destination:=Range("b1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, Tab:=True, Other:=True, OtherChar _
:=TextBox2, FieldInfo:=Array(Array(1, 1), Array(2, 1))
ActiveWindow.ScrollRow = 5
...wohingegen der gleiche Code, nur mit einer If-Abfrage, ob etwas in der Textbox steht, nicht funktioniert:
If TextBox1 = True Then
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("a1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, Tab:=True, Other:=True, OtherChar _
:=TextBox1, FieldInfo:=Array(Array(1, 1), Array(2, 1))
ActiveWindow.ScrollRow = 5
End If
If TextBox2 = True Then
Columns("B:B").Select
Selection.TextToColumns Destination:=Range("b1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, Tab:=True, Other:=True, OtherChar _
:=TextBox2, FieldInfo:=Array(Array(1, 1), Array(2, 1))
ActiveWindow.ScrollRow = 5
End If
Hier mal der ganze Code. Alles liegt auf einem Tabellenblatt...
Private Sub CommandButton1_Click()
Dim sFile As String, sPattern As String, sPath As String
Dim iRow As Integer
'Erste leere Zeile finden
iRow = 5
Do Until Application.WorksheetFunction.CountBlank(Rows(iRow)) = 256
iRow = iRow + 1
Loop
'damit ohne Leerzeile im Folgenden aufgesetzt werden kann:
iRow = iRow - 1
'Dateinamen einlesen
sPath = InputBox( _
prompt:="Pfad:", Default:="C:\Arcade\C64\ROMS")
If Right(sPath, 1) <> "\" Then sPath = sPath & "\"
sPattern = InputBox( _
prompt:="dateifilter:", Default:="*.d64")
sFile = Dir(sPath & sPattern)
Do Until sFile = ""
iRow = iRow + 1
Cells(iRow, 1).Value = sFile
sFile = Dir()
Loop
'Absteigend nach Spielenamen sortieren
Range("A5:L65000").Select
Selection.Sort Key1:=Range("A5"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A1").Select
End Sub
Private Sub CommandButton2_Click()
Dim iRow As Integer
'Erste leere Zeile finden
iRow = 5
Do Until Application.WorksheetFunction.CountBlank(Rows(iRow)) = 256
iRow = iRow + 1
Loop
If TextBox1 = True Then
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("a1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, Tab:=True, Other:=True, OtherChar _
:=TextBox1, FieldInfo:=Array(Array(1, 1), Array(2, 1))
ActiveWindow.ScrollRow = 5
End If
If TextBox2 = True Then
Columns("B:B").Select
Selection.TextToColumns Destination:=Range("b1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, Tab:=True, Other:=True, OtherChar _
:=TextBox2, FieldInfo:=Array(Array(1, 1), Array(2, 1))
ActiveWindow.ScrollRow = 5
End If
'Autofilter einfügen
Rows("4:4").Select
Selection.AutoFilter
Range("A1").Select
End Sub