Was ist hier falsch?
Zum Tabellenaufbau: Die Überschriften sind in der zweiten Zeile. Wenn eine Überschrift gefunden wird soll die Spalte ab der dritten Zelle entsprechend formatiert werden. Es tut sich allerdings nichts und ich komme nicht drauf.
Option Explicit
Sub CaseAnweisungTest()
Dim i As Long
For i = 1 To IIf(Len(Cells(2, Columns.Count)) = 0, Cells(2, Columns.Count).End(xlToLeft). _
Column, _
Cells(2, Columns.Count))
Select Case Cells(2, i)
Case "DATUM", "BUCHUNGSTAG", "BUCHDATUM"
With Range(Cells(3, i), Cells(100, i))
.NumberFormat = "m/d/yyyy"
.HorizontalAlignment = xlCenter
If .Application.WorksheetFunction.CountA(.Cells) > 0 Then
.TextToColumns Destination:=Cells(3, i), _
TextQualifier:=xlDoubleQuote, Tab:=True, _
Other:=False, FieldInfo:=Array(1, 1)
End If
End With
Case "PNR", "LA"
With Range(Cells(3, i), Cells(100, i))
.NumberFormat = "0"
If .Application.WorksheetFunction.CountA(.Cells) > 0 Then
.TextToColumns Destination:=Cells(3, i), _
TextQualifier:=xlDoubleQuote, Tab:=True, _
Other:=False, FieldInfo:=Array(1, 1)
End If
End With
Case "VEREINS" & Chr(10) & "KONTO" & Chr(10) & "NUMMER"
With Range(Cells(3, i), Cells(100, i))
.NumberFormat = "General"
.HorizontalAlignment = xlCenter
If .Application.WorksheetFunction.CountA(.Cells) > 0 Then
.TextToColumns Destination:=Cells(3, i), _
TextQualifier:=xlDoubleQuote, Tab:=True, _
Other:=False, FieldInfo:=Array(1, 1)
End If
End With
End Select
Next i
End Sub
Besten Dank für die Hilfe und Servus, Walter