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
Solved

Object Required error

Posted on 2015-02-17
6
111 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
  • 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 500 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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…

789 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