回答編集履歴
1
コード追記
test
CHANGED
@@ -30,3 +30,25 @@
|
|
30
30
|
あるいは、連想配列(Dictionaryオブジェクト)を使うと高速化できます。
|
31
31
|
|
32
32
|
|
33
|
+
エクセルのMatch関数を使って検索するコード例
|
34
|
+
```vba
|
35
|
+
Sub compare_date2()
|
36
|
+
|
37
|
+
Dim rStart As Range, rGoal As Range
|
38
|
+
With Sheets("start")
|
39
|
+
Set rStart = .Range(.Cells(2, "A"), .Cells(Rows.Count, "A").End(xlUp)) '日付データのセル範囲
|
40
|
+
End With
|
41
|
+
With Sheets("goal")
|
42
|
+
Set rGoal = .Range(.Cells(2, "A"), .Cells(Rows.Count, "A").End(xlUp)) '比較先の日付データのセル範囲
|
43
|
+
End With
|
44
|
+
|
45
|
+
Dim l As Variant, i As Long
|
46
|
+
For Each l In rStart
|
47
|
+
On Error Resume Next
|
48
|
+
i = WorksheetFunction.Match(l, rGoal, 0) 'Matchで一致データを検索
|
49
|
+
If Err.Number <> 0 Then MsgBox l.Row '一致データがないとエラーになるのでメッセージ表示
|
50
|
+
On Error GoTo 0
|
51
|
+
Next l
|
52
|
+
|
53
|
+
End Sub
|
54
|
+
```
|