LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Help with Exiting Sub if Value is Not Found

Hello-
I would like the code below to not go in debug mode if the variable a is not
found. What is the code I should insert? Thank you!

Public Sub Macro1()

Dim nRow As Integer, i As Integer, a As String

If Not Intersect(activecell, Range("A1:E77")) Is Nothing Then

a = Left(activecell.Offset(0, 5).Text, 9)

Sheets("MTD-DTB").Select
Range("A1").Select

Cells.Find(What:=a, After:=activecell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate

nRow = activecell.Row

For i = nRow To 1000

If Range("B" & i).Value = a Then

Range("A" & nRow, "G" & i).Select

End If

Next i

End sub
 
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
Exiting Excel MEAD5432 Excel Discussion (Misc queries) 2 December 7th 07 11:05 PM
Exiting a Textbox EGL Excel Programming 2 May 13th 07 09:49 AM
Exiting Worksheet Evan Excel Discussion (Misc queries) 1 February 11th 05 06:06 PM
Exiting a workbook Dick Kusleika Excel Programming 0 August 15th 03 05:30 PM
Exiting a workbook John Wilson Excel Programming 0 August 15th 03 04:43 PM


All times are GMT +1. The time now is 12:11 PM.

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

About Us

"It's about Microsoft Excel"