Home > OS >  Copy data based on multiple if statements
Copy data based on multiple if statements

Time:06-28

I am getting a run time error '438': object doesn't support this property or method on the IF statements. I am trying to copy data from one sheet to another given if all 4 if statements are met.

Sub update_cell1()

Dim lRow As Long

lRow = Cells(Rows.Count, 1).End(xlUp).Row

For i = 3 To lRow
   If Worksheets("TEST").Cells(i, 5).vlaue = Worksheets("Cell_1").cell(1, 2).Value Then 'B1
        If Worksheets("TEST").Cells(i, 1).vlaue = Worksheets("Cell_1").cell(1, 1).Value Then 'A1
            If Worksheets("TEST").Cells(i, 6).vlaue <> "" Then 'not blank
                If Worksheets("TEST").Cells(i, 8).vlaue <> "" Then 'not blank
                
                    Worksheets("TEST").Rows(i).Copy
                    Worksheets("Cell_1").Active
                    b = 5
                    Worksheets("Cell_1").Cells(b   1, 1).Select
                    ActiveSheet.Paste
                End If
            End If
        End If
      End If
    Next
    
Application.CutCopyMode = False
Worksheets("Cell_1").Active

End Sub

CodePudding user response:

Worksheets(..).Cells(...).vlaue should be corrected to Worksheets(..).Cells(...).Value

Worksheets(..).cells(...) should be corrected to Worksheets(..).Cells(...)

In VBA, properties are case-sensitive. That means object.prop is different than object.Prop

CodePudding user response:

Just syntax error - use Cells() instead of "cell()"

  • Related