Hello
I have a macro which works ok but I want to add an additional If statement.
At present this line
just adds the value 2 but I would like to change it so that it adds a 1 if the value in ThisCell2.(Offset(,3)is 1 or a 2 if the value in ThisCell2.(Offset(,3) is 2.
I've tried a few ways but I'm very much a VBA novice and don't seem to be able to add the If within the If.
Thank you
I have a macro which works ok but I want to add an additional If statement.
At present this line
Code:
ThisCell1.Offset(, 18).Value = 2
I've tried a few ways but I'm very much a VBA novice and don't seem to be able to add the If within the If.
Thank you
VBA Code:
Option Compare Text
Sub InsertDetails()
Dim ThisCell1 As Range
Dim ThisCell2 As Range
For Each ThisCell1 In ThisWorkbook.Sheets("Sheet1").Range("A5:A1000")
'This is the range of cells to check
For Each ThisCell2 In ThisWorkbook.Sheets("Sheet2").Range("A1:A10")
'This is the range of cells to compare
If ThisCell1 <> "" And ThisCell1.Value = ThisCell2.Value Then
ThisCell1.Offset(, 16).Value = "BK"
ThisCell1.Offset(, 17) = ThisCell2.Offset(, 4).Value
ThisCell1.Offset(, 18).Value = 2
Exit For
End If
Next ThisCell2
Next ThisCell1
End Sub