VBA - Help on Object Variable or With block variable not set

szita2000

Board Regular
Joined
Apr 25, 2012
Messages
101
Office Version
  1. 365
Platform
  1. Windows
Hi guys. I can't make this error to go away.
Basically it is part of a loop where first we find a separate table in the bottom of a crystal style report, then we look in the shortened range (ErrorMachinerng)
I get an Object Variable or With block variable not set error on the
NumberOfStops = ErrorMachinerng.Find(What:=MachineToLookfor).Offset(0, 20).Value row

The NumberOfStops is declared as Long, and the data I am trying to get from the table is a Number which I confirmed with a formula.

Let me know if needed I can post the whole code.

Code:
TomisRow = searchrange.Find(What:="Tomi Error Evaluation").Row + 5    Debug.Print "Tomisrow = " & TomisRow
Set smallsearchrange = Range("A" & TomisRow & ":A1000")
FindTotalRowBeneathTomi = smallsearchrange.Find(What:="Total").Row - 2
    Debug.Print "Total row on the bottom = " & FindTotalRowBeneathTomi
Set ErrorMachinerng = Range("B" & TomisRow + 5 & ":B" & FindTotalRowBeneathTomi)


NumberOfStops = ErrorMachinerng.Find(What:=MachineToLookfor).Offset(0, 20).Value
    Debug.Print "Number of stops are: " & NumberOfStops


foundmachineToPaste.Offset(5, (CorrectColumn.Column) - 1).Value = NumberOfStops


Next i
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
One possibility is that it can't find "MachineToLookfor" in column B
 
Upvote 0
Hi Fluff.
That was it!
I checked the address of the searched range, and I managed to screw it up by 5 row (you can see it in the posed code's first row).
Thanks! Thanks! Thanks!
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,913
Members
449,093
Latest member
dbomb1414

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