Object Required Error Message Help

sambradley

New Member
Joined
Jul 21, 2017
Messages
5
So I am trying to create a macro that reads the value in my Worksheets('Main Page").Range("B13") and then goes and searches through the rest of my sheets and will delete that entire row, in which the value is found. I am receiving an error that says "Object Required". Any help would be great.

My code is the following:

<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #011993; background-color: #ffffff}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; background-color: #ffffff; min-height: 13.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}span.s1 {color: #011993}span.s2 {color: #000000}</style>Sub Delete_Customer_By_Order_Num()


Dim xRg As Range
Dim xCell As Integer


Set xRg = AllWorksheets.Range("B1:B")


Set xCell = Worksheets("Main Page").Range("B13")


For Each xCell In xRg
xCell.EntireRow.Delete


Next


Application.Scre


<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #fffb00}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; background-color: #ffffff; min-height: 13.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #011993; background-color: #ffffff}span.s1 {color: #011993}span.s2 {color: #000000}</style>
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hello and welcome on the forum,

I think I will translate your code for you in normal text, you will see yourself your problem

Declare 1 variable for range and 1 for number
Set the range on all B column in workbook
Set the number on B13 value (if B13 value is a text, you will have an error here)
For each number in the range (Normally you do : for each range in the range)
Delete the row (???)
Next number (Next number? but you only have 1)
??? Application.scre ??? (That don't exist)

Edit : Don't worry, if you don't know how to do something we can help you
 
Last edited:
Upvote 0
Wow, I am new to code and vba but did not exactly notice all those mistakes.

I have simplified a bit and am still receiving an error called "Application-defined or Object-defined error"

Updated code:
Code:
<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #011993; background-color: #ffffff}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; background-color: #ffffff; min-height: 13.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}span.s1 {color: #011993}span.s2 {color: #000000}</style>Sub Delete_Customer_By_Order_Num()


    Dim xCells As String
    Dim xTrigger As Range


    xCells = Worksheets("Main Page").Range("B13")
    Set xTrigger = Worksheets("Main Page").Range("C13")


    If xTrigger.Value = "Yes" Then
        Range(xCells).Value = "DONE"
    End If
[COLOR=#011993][FONT=Menlo]End[/FONT][/COLOR][FONT=Menlo] [/FONT][COLOR=#011993][FONT=Menlo]Sub
[/FONT][/COLOR]
 
Upvote 0
Your problematic is that you are saving in your variable xCells is the value of the cell B13.
By doing that, you are later trying to use that as a range, but it can't work.

You have 2 posibility to solve this. The first one is change your xcells variable to a range and set it like xtrigger.
The second one is to put quotation mark around the target that you want to set.

Here is the 2 possible line

Code:
Set xCells = Worksheets("Main Page").Range("B13")
'or
xCells = "Worksheets("Main Page").Range("B13")"
 
Upvote 0
Where exactly are you looking for the value that's in B13 on 'Main Page's?
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

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