Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Error if can't find text

The following code basically does a find in the list of
rows and blank the row that matches RemoveEmp. If the
exact text of RemoveEmp cannot be found, nothing happens.

What can be added to the following code so that if the
exact code cannot be found, an error message appears?


'Find RemoveEmp Name in Text and Set values in line equal
to " "
Count = 0
Do While Count < 60
Count = Count + 1
If ActiveSheet.Cells(Count, 1) = RemoveEmp Then
ActiveSheet.Cells(Count, 1).Activate
ActiveCell.EntireRow.Value = ""
End If
Loop

Thanks

SS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Error if can't find text

Do you mean if the text is never found during the entire looping
process? If so, try the amended code:

Dim Found As Boolean
Dim Count As Long
Do While Count < 60
Count = Count + 1
If ActiveSheet.Cells(Count, 1) = RemoveEmp Then
ActiveSheet.Cells(Count, 1).Activate
Found = True
ActiveCell.EntireRow.Value = ""
End If
Loop
If Found = False Then
MsgBox "Not Found"
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"S. S." wrote in message
...
The following code basically does a find in the list of
rows and blank the row that matches RemoveEmp. If the
exact text of RemoveEmp cannot be found, nothing happens.

What can be added to the following code so that if the
exact code cannot be found, an error message appears?


'Find RemoveEmp Name in Text and Set values in line equal
to " "
Count = 0
Do While Count < 60
Count = Count + 1
If ActiveSheet.Cells(Count, 1) = RemoveEmp Then
ActiveSheet.Cells(Count, 1).Activate
ActiveCell.EntireRow.Value = ""
End If
Loop

Thanks

SS



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error dialog box meaning and how to find error Jeanne Excel Worksheet Functions 2 September 4th 08 04:59 AM
Search, find or lookup defined text in text string zzxxcc Excel Worksheet Functions 9 September 6th 07 09:37 PM
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
how to find an error nastech Excel Discussion (Misc queries) 0 July 12th 06 04:59 AM
help with this error-Compile error: cant find project or library JackR Excel Discussion (Misc queries) 2 June 10th 06 09:09 PM


All times are GMT +1. The time now is 10:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"