Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 96
Default How to say do nothing

I use this macro I recorded to clear O from my worksheet. If there are no O's
I get an error in the VB debugger. What do I need to add to tell it to do
nothing if there are no O's.?

Sheets("Reg Positions").Select
Range("A6:E700").Select
Selection.sort Key1:=Range("A6"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Cells.Find(What:="O", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate
Cells.Replace What:="O", Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How to say do nothing

It looks to me like you could just delete that .Find line.

chrisnsmith wrote:

I use this macro I recorded to clear O from my worksheet. If there are no O's
I get an error in the VB debugger. What do I need to add to tell it to do
nothing if there are no O's.?

Sheets("Reg Positions").Select
Range("A6:E700").Select
Selection.sort Key1:=Range("A6"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Cells.Find(What:="O", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate
Cells.Replace What:="O", Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 96
Default How to say do nothing

That did it. Thanks

"Dave Peterson" wrote:

It looks to me like you could just delete that .Find line.

chrisnsmith wrote:

I use this macro I recorded to clear O from my worksheet. If there are no O's
I get an error in the VB debugger. What do I need to add to tell it to do
nothing if there are no O's.?

Sheets("Reg Positions").Select
Range("A6:E700").Select
Selection.sort Key1:=Range("A6"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Cells.Find(What:="O", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate
Cells.Replace What:="O", Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False


--

Dave Peterson

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



All times are GMT +1. The time now is 07:58 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"