Run-time error 91

miami2k

Board Regular
Joined
Nov 1, 2017
Messages
58
Dear All,
When I debug my code and try o restart a Userform I get this message...
runtime error 91 object variable or with block variable not set

I close and save, reopen the file and everything works fine until I have to debug again for any reason. So I have to keep saving, closing and restarting.

I've run a search in the project and I used "with" only in two ways in my code, here they are:

===============================

VBA Code:
Sub PopolaCompl()

Dim rng As Range
Dim Cel1 As Range
Dim LR As Long
Dim ws As Worksheet
Set ws = Sheets("Filed")
With ws

LR = .Cells(.Rows.Count, "B").End(xlUp).Row

Scadenziario.ListBox2.Clear

If LR = 1 Then GoTo Finished Else

Set rng = .Range("A1:A" & LR).SpecialCells(xlCellTypeVisible)
With Scadenziario.ListBox2

  .ColumnCount = 9
  .ColumnWidths = "0;180;120;60;60;60;60;270;60;"

For Each Cel1 In rng
.AddItem CStr(Cel1.Value)
.List(.ListCount - 1, 0) = Cel1.Offset(0, 0).Value
.List(.ListCount - 1, 1) = Cel1.Offset(0, 1).Value
.List(.ListCount - 1, 2) = Cel1.Offset(0, 2).Value
.List(.ListCount - 1, 3) = Cel1.Offset(0, 3).Value
.List(.ListCount - 1, 4) = Cel1.Offset(0, 4).Value
.List(.ListCount - 1, 5) = Cel1.Offset(0, 5).Value
.List(.ListCount - 1, 6) = Cel1.Offset(0, 6).Value
.List(.ListCount - 1, 7) = Cel1.Offset(0, 7).Value
.List(.ListCount - 1, 8) = Cel1.Offset(0, 8).Value
Next Cel1
End With
End With

Finished:

End Sub

=================================
and ...
=================================

VBA Code:
Private Sub CommandButton10_Click()

With Scadenziario
    .ComboBox13.ListIndex = 0
End With

End Sub

==========================

Any tip to solve the issue?


Thank you,


miami2k
 
Can I upload the full file?

I've deleted all the parts of the code including "WITH" but anytime a launch any userform I get the same error. But only if I debug. If I don't the project runs smoothly.
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Can I upload the full file?

I've deleted all the parts of the code including "WITH" but anytime a launch any userform I get the same error. But only if I debug. If I don't the project runs smoothly.

you can place your file in a dropbox & post a link to it here -

When posting code on the forum need to use code Tags shown in Tool bar <vba> Press that & place your code between the tags - you may get lucky & MOD correct the post for you.

Dave
 
Upvote 0
Please try to use CODE tags when you post VBA code here on the forum (select your code, then use the "<vba/>" button on the post editor menu bar above to wap your code with CODE tags). It makes your code a lot easier for everyone else to read.
 
Upvote 0

Forum statistics

Threads
1,216,172
Messages
6,129,290
Members
449,498
Latest member
Lee_ray

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top