|
こんにちは
DB2のどこを検索するのか分からないですし、判定ロジックもあやふやですけど、
Private f As Range
Sub test()
Dim r As Range
Dim t As Range
Dim b As Boolean
'DB2のどこを検索するのか
Set t = Worksheets("DB2").Range("A1").CurrentRegion.Columns(1)
With Worksheets("DB1")
For Each r In .Range("B8", .Cells(Rows.Count, 2).End(xlUp))
Select Case r.EntireRow.Range("E1").Value
Case "クローズ"
Select Case r.EntireRow.Range("AL1").Value
Case "オープン"
b = False
Case "クローズ"
b = Search_DB2(r.EntireRow.Range("AK1").Value, t) * False
Case ""
End Select
Case Else
Select Case r.EntireRow.Range("AL1").Value
Case "オープン"
b = Search_DB2(r.EntireRow.Range("AK1").Value, t) * False
Case "クローズ"
b = Search_DB2(r.EntireRow.Range("AK1").Value, t)
Case ""
End Select
End Select
If b = False Then
r.Interior.ColorIndex = 3
End If
Set f = Nothing
Next
End With
End Sub
Function Search_DB2(ByVal s As Variant, Target As Range) As Boolean
Set f = Target.Find(s, , xlValues, xlWhole)
If f Is Nothing Then
Search_DB2 = False
Exit Function
End If
If f.EntireRow.Range("D1").Value Like "*クローズ*" And _
IsNumeric(f.EntireRow.Range("N1").Value) = True Then
Search_DB2 = True
Else
Search_DB2 = False
End If
End Function
|
|