AW: Fragen
23.01.2012 14:34:41
Rudi
Hallo,
in ein Modul:
Sub Zahl()
Dim lngZahl As Long, arr(), lngRow As Long, lngCount As Long, lngCounter As Long
Dim wksAuftrag As Worksheet, wksErfassung As Worksheet
Set wksErfassung = ThisWorkbook.Sheets(1)
lngZahl = Application.InputBox("Zahl?", "Eingabe", Type:=1)
If lngZahl > 0 Then
On Error Resume Next
Set wksAuftrag = Workbooks("Auftrag.xls").Sheets("Daten")
On Error GoTo 0
If wksAuftrag Is Nothing Then
Set wksAuftrag = Workbooks.Open(ThisWorkbook.Path & "\Auftrag.xls").Sheets("Daten")
End If
With wksAuftrag
lngCount = Application.CountIf(.Columns(4).lngZahl)
If lngCount = 0 Then
MsgBox lngZahl & " nicht vorhanden.", vbOKOnly, "Gebe bekannt..."
Else
ReDim arr(1 To lngCount, 1 To 1)
For lngZahl = 1 To .Cells(Rows.Count, 4).End(xlUp).Row
If .Cells(lngRow, 4) = lngZahl Then
lngCounter = lngCounter + 1
arr(lngCounter, 1) = .Cells(lngRow, 1)
End If
Next
End If
End With
With wksErfassung
.Columns(26).ClearContents
.Cells(1, 26).Resize(lngCount) = arr
End With
End If
End Sub
Ungetestet.
Auftrag und Erfassung im selben Ordner.
Gruß
Rudi