Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Object Required error

Posted on 2015-02-17
6
Medium Priority
?
116 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
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.

 

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

609 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