| 
    
     |  | まゆん さん、こんばんわ。 
 >あの〜。恐れ入りますもうひとつ質問させてください。
 >ExcelのCellの中に下記のような表があると例えます。
 
 >A1  データ
 >A2 001
 <<略>>
 >A9 006
 >A10 007
 
 >上記の表を例にすると答えは6です。
 だとして。
 
 Sub Test()
 With Range("A1:A10")
 .AdvancedFilter Action:=xlFilterInPlace, Unique:=True
 'Rangeは分断されていると一番上だけしかCountで返さなくなるので
 'Areasで全部チェックして足していく
 For Each c In .SpecialCells(xlCellTypeVisible).Areas
 RR& = RR& + c.Rows.Count
 Next
 '1行目はタイトル行なのでデータの行数は -1
 MsgBox RR& - 1, vbInformation, "Unique"
 End With
 
 End Sub
 
 ベタに数えていく場合
 Sub test()
 Dim Rmax&, Rpos&, Flg As Boolean
 Rmax& = 10 'A10まで検索するとして
 Rpos& = 0
 ReDim cdat(1 To Rmax&) As Variant '内容保管用
 '
 For RR& = 2 To Rmax&
 With Cells(RR&, 1)
 If .Value <> "" Then
 Flg = True
 For NN& = 1 To Rpos&
 If cdat(NN&) = .Value Then
 Flg = False: Exit For
 End If
 Next
 'チェック後重複が無ければ配列に入れる
 If Flg = True Then
 Rpos& = Rpos& + 1
 cdat(Rpos&) = .Value
 End If
 End If
 End With
 Next
 MsgBox Rpos&, vbInformation, "Unique"
 Erase Cdat
 End Sub
 
 ichinoseさんの配列数式も面白そうですね。
 
 
 |  |