So I have used the same code just changing the variable names several times without any issues until now. The following code gives me the infamous 91 error Object variable or With block not set.
The line ==> Set tblr = wsANI.Range("A1")
Gives me the error. If I comment out the line, the code works fine.
I have used the trick by resetting and using the break a few times and reset again just to make sure nothing weird has happened to my excel file. I have looked at several posts trying to find an answer as to what I am missing and they all say to add "Set" because that is what most are missing. That is not the case here.
Can someone help me please.
Thank you
Michael Libeson
Code:
Sub GetANITESTLIST()
' Declare variables
Dim qry As String
Dim qt As QueryTable
Dim tblr As Range
Dim LastRow, i As Long
Dim wsANI As Worksheet
' Initialize Variables
Set qt = Nothing
Set tblr = Nothing
Set asANI = ActiveWorkbook.Sheets("ANITESTLIST")
' Activate Worksheet
asANI.Visible = True
asANI.Activate
LastRow = asANI.Cells(65000, 1).End(xlUp).Row
asANI.Range("A" & (LastRow + 1)) = "BYE"
' Set Query Result Destination
Set tblr = wsANI.Range("A1")
' Clear variables
Set qt = Nothing
Set tblr = Nothing
Set wsANI = Nothing
End Sub
The line ==> Set tblr = wsANI.Range("A1")
Gives me the error. If I comment out the line, the code works fine.
I have used the trick by resetting and using the break a few times and reset again just to make sure nothing weird has happened to my excel file. I have looked at several posts trying to find an answer as to what I am missing and they all say to add "Set" because that is what most are missing. That is not the case here.
Can someone help me please.
Thank you
Michael Libeson