Solved

if it can't be found end sub

Posted on 2014-03-19
2
199 Views
Last Modified: 2014-03-19
I am using the below code to find text. What I need is to say if the word[s] cannot be found End Sub. Can an expert provide me with the additional code that will do this please.

Rows("1:" & Cells.Find("Open and Closed").Row - 1).Delete

Thanks
0
Comment
Question by:Jagwarman
2 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 total points
ID: 39939004
Dim FoundCell As Range
Set FoundCell = Cells.Find("Open and Closed")
If FoundCell Is Nothing Then Exit Sub
Rows("1:" & FoundCell.Row - 1).Delete

Kevin
0
 

Author Closing Comment

by:Jagwarman
ID: 39939009
Thanks Kevin exactly what I wanted.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ActiveX Listbox Multi Select in Excel 2010 8 16
File not loading into PowerPivot 4 9
IF ELSE Statement in Excel Macro VBA 16 30
Help Updated Qtr 2 9
INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

912 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

23 Experts available now in Live!

Get 1:1 Help Now