Hallo crs,
warum sind so viele Leute nicht bereit, wenigstens ihren Vornamen zu nennen? Oder ist das die Abkürzung von cannot read, sorry?
Also zu deinem Problem, das ich allerdings von dseinem Code her nicht nachvollzogen habe. Ich hasse WorksheetFunctions, weil man nie so genau weiß, was die wirklich machen. deshalb hier ein Quick-and-Dirty-Ansatz für eine Spalte, den du sicherlich leicht anpassen kannst und musst:
dimz = 1
ReDim z(1, 1)
sp = InputBox("Spaltenbezeichnung")
If IsNumeric(sp) Then
sp = Val(sp)
Else
sp = Cells(1, sp).Column
End If
lz = Cells(Rows.Count, sp).End(xlUp).Row
If Cells(1, sp) = "" And lz = 1 Then MsgBox "Leere Spalte": Exit Sub
z(0, 1) = Cells(1, sp)
z(1, 1) = 1
For i = 2 To lz
If Cells(i, sp) <> Empty Then
k = False
For j = 1 To UBound(z, 2)
If z(0, j) = Cells(i, sp) Then k = True: Exit For
Next j
If k = False Then
dimz = dimz + 1
ReDim Preserve z(1, dimz)
z(0, j) = Cells(i, sp)
End If
z(1, j) = z(1, j) + 1
End If
Next i
a = ""
For i = 1 To UBound(z, 2)
a = a + z(0, i) + " - " + CStr(z(1, i)) + vbCrLf
Next i
MsgBox a
Gruß
Holger
|