Cozkincaud
New Member
- Joined
- Apr 18, 2019
- Messages
- 8
Hi
I need help with what should be a simple macro.
I need to search a column of book/article titles to find a book/article title that I paste into an Excel Find box.
I created a macro from some Internet posts, but get the error, “Run-time error ‘91’: Object variable or With block variable not set”.
This is the macro:
Sub CheckIfOneTabFilesDownloaded()
' Macro to check if Internet tabs sent to One Tab have already been downloaded
Dim Title As String
Sheets("Downloads - November 18, 2023").Select
ActiveSheet.Range("A1:A1").Select
Title = InputBox("Enter Title")
Dim fColumn As Range
Set Rng = Find(What:=Title, LookAt:=xlPart, LookIn:=xlValues, MatchCase:=False, After:=fColumn("A2"))
If fColumn Is Nothing Then
MsgBox "Nothing found"
Else:
fColumn.Activate
End If
End Sub
with the error line being the “Set Rng . . . “ statement.
My understanding is I am attempting to use an object variable that has yet to reference a valid object. The error is in the "Set Rng' statement. I assume the following lines are fine.
After an Internet search I added “Cells.Find” to my “Set Rng” statement but to no avail.
So I would be extremely grateful for whatever help and suggestions forum members can give.
My thanks in advance for whatever help and advice
I need help with what should be a simple macro.
I need to search a column of book/article titles to find a book/article title that I paste into an Excel Find box.
I created a macro from some Internet posts, but get the error, “Run-time error ‘91’: Object variable or With block variable not set”.
This is the macro:
Sub CheckIfOneTabFilesDownloaded()
' Macro to check if Internet tabs sent to One Tab have already been downloaded
Dim Title As String
Sheets("Downloads - November 18, 2023").Select
ActiveSheet.Range("A1:A1").Select
Title = InputBox("Enter Title")
Dim fColumn As Range
Set Rng = Find(What:=Title, LookAt:=xlPart, LookIn:=xlValues, MatchCase:=False, After:=fColumn("A2"))
If fColumn Is Nothing Then
MsgBox "Nothing found"
Else:
fColumn.Activate
End If
End Sub
with the error line being the “Set Rng . . . “ statement.
My understanding is I am attempting to use an object variable that has yet to reference a valid object. The error is in the "Set Rng' statement. I assume the following lines are fine.
After an Internet search I added “Cells.Find” to my “Set Rng” statement but to no avail.
So I would be extremely grateful for whatever help and suggestions forum members can give.
My thanks in advance for whatever help and advice