Solved

Object Required error

Posted on 2015-02-17
6
106 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now