wrote :: 2006.01.04

Sub Sample02()
Dim i As Long, cnt As Long
For i = 1 To 11
If ActiveSheet.Cells(i, 1) = "A001" Then cnt = cnt + 1
Next i
MsgBox "A001は、" & cnt & "件です。", vbInformation
End Sub
Sub Sample02_2()
Dim i As Long, cnt As Long
i = 1
Do While ActiveSheet.Cells(i, 1) <> ""
If ActiveSheet.Cells(i, 1) = "A001" Then cnt = cnt + 1
i = i + 1
Loop
MsgBox "A001は、" & cnt & "件です。", vbInformation
End Sub
Sub Sample02_3()
Dim cnt As Long
cnt = WorksheetFunction.CountIf(ActiveSheet.Range("A1:A11"), "A001")
MsgBox "A001は、" & cnt & "件です。", vbInformation
End Sub
Sub Sample02_4()
Dim cnt As Long, tmpSheet As Worksheet, dataSheet As Worksheet
Application.ScreenUpdating = False
Set dataSheet = ActiveSheet
Set tmpSheet = Worksheets.Add
dataSheet.Activate
Range("A1").Select
With Selection
.AutoFilter Field:=1, Criteria1:="A001"
.CurrentRegion.SpecialCells(xlCellTypeVisible).Copy tmpSheet.Range("A1")
cnt = tmpSheet.UsedRange.Rows.Count
.AutoFilter
Application.DisplayAlerts = False
tmpSheet.Delete
Application.DisplayAlerts = True
End With
Application.ScreenUpdating = True
MsgBox "A001は、" & cnt - 1 & "件です。", vbInformation
End Sub