• 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.

I get a VBA Excel 'Compiler Error: Object required'-Error. I am new to VBA coding, any help is aspir

Bob G.

Member
Code:
Sub TF()
  Dim rng As Range
  Dim i As Long
  Dim TF As Long 'Value 'Range
  Set TF = Application.Match("TF", Sheets("Update").Range("1:1"), False) '.Value
 
  With ActiveSheet
  Set rng = .Range("A1:A" & .Cells(.Rows.Count, 1).End(xlUp).Row)
  For i = 2 To rng.Rows.Count
  rng.Cells(i, 4) = Application.WorksheetFunction.VLookup(.Cells(i, 1), Sheets("Update").Range("A:AZ"), TF, False)
  Next
  End With
End Sub
 
The 'Set' method is used to define Objects. However, your TF variable is a Long (a number). So, change this line:
Set TF = Application.Match("TF", Sheets("Update").Range("1:1"), False) '.Value
to this"
TF = Application.Match("TF", Sheets("Update").Range("1:1"), False) '.Value
 
Back
Top