?
Solved

Object Required error

Posted on 2015-02-17
6
Medium Priority
?
115 Views
Last Modified: 2015-02-17
I have the below code that is falling over with Object Required

It deletes all the items it is looking for and if there is other data in the cell it continues through to the next piece of code but if all the cells are blank it fall over.

Can an expert help please


Set SrchRng = ActiveSheet.Range("A2", ActiveSheet.Range("A65536").End(xlUp))
    Do
        Set c = SrchRng.Find("GD Market*", LookIn:=xlValues)
        If Not c Is Nothing Then c.EntireRow.Delete
    Loop While Not c Is Nothing
   
    Range("A2").Select
         If ActiveCell = "" Then Exit Sub
0
Comment
Question by:Jagwarman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40614060
I don't get that error. Can you please publish your workbook.
0
 

Author Comment

by:Jagwarman
ID: 40614081
Sheet 2 works fine Sheet 1 gets the error
Object-Error.xlsm
0
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 2000 total points
ID: 40614095
This works:
 
Sub RemoveSome()
 
Set srchrng = ActiveSheet.Range("A2", ActiveSheet.Range("A65536").End(xlUp))
    Do
        Set c = srchrng.Find("GD Market*", LookIn:=xlValues)
        If Not c Is Nothing Then
            If srchrng.Rows().Count = 1 Then
                c.EntireRow.Delete
                Exit Do
            Else
                c.EntireRow.Delete
            End If
        End If
    Loop While Not c Is Nothing
   
    Range("A2").Select
         If ActiveCell = "" Then Exit Sub
        
      Sheets("Sheet2").Select
        
End Sub

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Jagwarman
ID: 40614114
Yes it does, many thanks
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40614121
It's because your search range went down to zero rows, which makes it not a valid range.
0
 

Author Comment

by:Jagwarman
ID: 40614130
Ah right thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question