• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Nested VBA If...End if not working

Sub check()
Dim j As Integer

a = Sheet2.Range("a2").CurrentRegion.Rows.Count

For j = 2 To a Step 1

If (Sheet4.Cells(4, 15) = Sheet3.Cells(j, 53)) = True Then
If (Sheet4.Cells(4, 16) = Sheet3.Cells(j, 52)) = True Then
Sheet3.Cells(j, 53) = Sheet4.Cells(4, 20)
Sheet3.Cells(j, 40) = Sheet4.Cells(4, 21)
End If
End If

Next j

While running this code, when line 1 and line 2 is true, line 4 and line 5 is executing. Could anyone help me on this ?
 
Your IF formula is incorrect can't seem to figure out what exactly you're trying to do. What is the True for since you're using the =

By the looks of it the For runs the code against every used row

Line 1 checks Sheet4 cell O4 against current row in column BA of Sheet3 to see if criteria match
If criteria matches then Line 2 checks Sheet4 cell P4 against current row in column AZ of Sheet3 to see if criteria match again
If match then it runs Line 3 which changes value in Sheet3 current row BA column to match Sheet4 cell T4 and Line 4 changes value in Sheet3 current row AN column to match Sheet4 cell U4

Is this correct & what are you trying to do exactly in your code
 
Back
Top