VBA Run-time Error '91' Object-variable or With block variable not set

preview_player
Показать описание
Grab the Free VBA Quick Reference Guide
There are things that must be done when creating an object variable. First you must declare the object variable with a Dim statement and then then you must assign the proper object with a Set statement.

This error can occur on a single line of code or within a With Statement

Want More check out this link
Рекомендации по теме
Комментарии
Автор

Thank you. Helpful. I was trying to assign an object by returning it from a function and I didn't use 'set' during the assignment. Thanks.

josdea
Автор

Way too complicated for the layperson like me, but I do always appreciate someone taking the time to try to help.

krausecommercialpainting
Автор

I got this exact error but for a totally different reason. That's the issue with programming errors, 50 issues throw the same error. In my case, user wrote macro in Excel 2010 and it failed when running in Excel 2013 or higher. Debugging it, I found an ActiveSheet.Next.Select command except the workbook it created only had one sheet and it threw this same 91 error. 2010 defaults to 3 sheets on new workbook, newer versions don't. Once I changed the default to three sheets when creating new workbooks, the macro ran fine.

onlywenilaugh
Автор

Helped me understand what it is but doesnt really apply to the code im writing. Even though it generates the same error.

Garycarlyle
Автор

I want to know how to fix them, not create them.

bastiat
Автор

Hello, I have a problem when my userform is run, I can't open others workbooks ?

excitingvision
Автор

I have this error on a code, once that i apply values for the data. Otherwise if i work with text records it will work.
Any suggestions for this?

dongobierno
Автор

I'm getting this error on an excel spreadsheet that worked previously and works on other PCs. There's a button in the spreadsheet that we use to refresh/update the spreadsheet. Any suggestions on why it would all of a sudden not work for one user?

jot
Автор

I have given the code of on erro goto but even thought I m getting run time error 91 pls advise

vinoth
Автор

So I'm coming up with the run time 91 error. I'm trying to use a button such that it filters a list of names (in column 1) and color (in column 2) into a ComboBox (i.e. like a drop down). Here's my code, but still running into problems

Private Sub FilterButton_Click()
Dim myLR As Range
Dim myColor As Range
Dim X As Integer
Dim ThisWorkbook As Workbook
Set ThisWorkbook = ActiveSheet
ThisWorkbook.Sheets = "PracticeDropDown"

myLR = ThisWorkbook.Sheets("PracticeDropDown").Cells(Rows.Count, 1).End(xlUp).Row
myColor = Range("k6")

For X = 2 To myLR
If Cells(X, 2) = myColor Then
Me.CmbBox2.AddItem Cells(X, 1)
End If

Next


End Sub

When I press F8 it doesn't like the ThisWorkbook.Sheets = "PracticeDropDown" ("Compile error: Invalid use of property"). Any idea what's up? Thanks for your time and assistance.

jonosuav
Автор

hi,

I'm trying to come up with a script that should choose a specific CMS Server before running the script for export of the report.

the code for the report is below.

vDate =
If IsDate(vDate) Then
Set fso =
Set AllDate = + "\Date.txt", 2, True) '2=for writing
AllDate.Write vDate
Set fso = Nothing

Dim objW As Object
Set objW =
If = "Hourly") Then
objW.Open ThisWorkbook.Path & "\Export Data-Agent Group Report.acsup"
objW.Open ThisWorkbook.Path & "\Export Data-SplitSkill Report.acsup"
Else
objW.Open ThisWorkbook.Path & "\Export Data-Agent Group Report.acsup"
objW.Open ThisWorkbook.Path & "\Export Data-SplitSkill Report.acsup"

End If
Set objW = Nothing
Else
v = MsgBox("Please enter a valid date.", vbCritical, "Verizon RTA")

End If

Now i'm having a hard time inserting a script to choose a specific CMS Server.

Just to simplify, the steps should be:
1. Click the button with the assigned macro.
2. Script should automatically choose from a set of CMS Servers (e.g. 10.1.1, 10.1.2, .., 10.1.5) - script should automatically choose 10.1.3. This also assumes that I am already logged in in the CMS Servers.
3. After 'automatically choosing the CMS Server, script should proceed with the exporting of the report.

Gladly appreciate if you could help me.

adder
Автор

run time error "-2147023170 (800706be). Pls help me fix the this error. Many thank

SOnNGuyen-fsre
Автор

While your video is interesting the typing errors and constant correcting take away so much from it that I downvoted you.

owenbonner
visit shbcf.ru