|
▼momoiro さん:
こんにちは
要件を取り間違えているかもしれませんが。
(Matchを 照合型0 という効率の悪い方法で使っていますがご容赦)
Sub Sample()
Dim msWB As Workbook, dtWB As Workbook
Dim msSH As Worksheet, dtSH As Worksheet
Dim tblA As Range
Dim i As Long
Dim ck As Variant
Application.ScreenUpdating = False
Set msWB = Workbooks.Open(ThisWorkbook.Path & "\マスター.xls")
'もし、既に開かれているなら Set msDB = Workbooks("マスター.xls")
Set dtWB = Workbooks.Open(ThisWorkbook.Path & "\対象一覧.xls")
'もし、既に開かれているなら Set dtDB = Workbooks("対象一覧.xls")
Set msSH = msWB.Worksheets("Sheet1")
Set dtSH = dtWB.Worksheets("Sheet1")
With msSH
Set tblA = .Range("A1").Resize(.Range("A" & .Rows.Count).End(xlUp).Row)
End With
With dtSH
For i = 1 To .Range("A" & .Rows.Count).End(xlUp).Row
ck = Application.Match(.Cells(i, "A").Value, tblA, 0)
If IsNumeric(ck) Then
msSH.Cells(ck, msSH.Columns.Count).End(xlToLeft).Offset(0, 1).Value = 9
End If
Next
End With
Set msWB = Nothing
Set dtWB = Nothing
Set msSH = Nothing
Set dtSH = Nothing
Application.ScreenUpdating = True
End Sub
|
|