I have a little problem with vba. I want to use Rows.Count but it will not count right.
In my sheet "thisyear" I want to filter some project numbers. When I filter I will get a list that has a different lenght, sometimes there are 5 rows in one project number and sometimes 10. Also sometimes it´s empty. That´s why I select all rows from 2 to 100, cut off all empty rows and than want to use the Rows.Count function. But it will not count in the right way. In project-number1 are 3 rows, but the msgBox give me the number 99 and I don´t know why.
Sheets("thisyear").Range("$A$1:$J$735").AutoFilter Field:=4, Criteria1:= _
"project-number1"
Rows("2:100").Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
MsgBox Selection.Rows.Count
I hope someone can help me!
The complete code:
Sheets("August").Range("$A$1:$J$735").AutoFilter Field:=4, Criteria1:= _
"project-number1"
Rows("2:3000").Select
Selection.SpecialCells(xlCellTypeConstants, 23).Select
If Selection.Rows.Count >= "30" Then
Sheets("Daten-August").Select
LastCellColRef = 1
Set LastCell = Sheets("Daten-August").Cells(Rows.Count, LastCellColRef).End(xlUp).Offset(1, 0)
Range(LastCell.Address).Select
ActiveCell.FormulaR1C1 = "_"
Else
Selection.Copy
Sheets("Daten-August").Select
LastCellColRef = 1
Set LastCell = Sheets("Daten-August").Cells(Rows.Count, LastCellColRef).End(xlUp).Offset(1, 0)
Range(LastCell.Address).Select
Sheets("Daten-August").Paste
Set LastCell = Sheets("Daten-August").Cells(Rows.Count, LastCellColRef).End(xlUp).Offset(1, 0)
Range(LastCell.Address).Select
ActiveCell.FormulaR1C1 = "_"
End If