Do Until Loop Causing Problems

jayor215

New Member
Joined
Sep 23, 2013
Messages
43
This code is giving me the error of Object Variable or With Block Variable not set. Why is this?

Thank you in advance.

Code:
Sub SetRowCnt()
    
    Dim r As Range
    
    r = 1
    Do
        r = r + 1
    Loop Until ActiveWorkbook.Sheets("Specific Records").Cells(r, 1).Value = "Use this Record"


End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
This code is giving me the error of Object Variable or With Block Variable not set. Why is this?

Thank you in advance.

Code:
Sub SetRowCnt()
    
    Dim r As Range
    
    r = 1
    Do
        r = r + 1
    Loop Until ActiveWorkbook.Sheets("Specific Records").Cells(r, 1).Value = "Use this Record"


End Sub

Of course. I declared it as a range so it was looking for "Set." Considering the code I change it to Dim r as String.

If any other good learning opportunities from above, please let me know, otherwise, I'll consider it closed.

Thank you all.
 
Upvote 0

Forum statistics

Threads
1,203,690
Messages
6,056,755
Members
444,889
Latest member
ibbara

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