Proceeding to the next line

rholdren

Board Regular
Joined
Aug 25, 2016
Messages
140
Office Version
  1. 365
  2. 2019
First, Happy Valentines day everyone. May this be the best one ever :)

I've been looking around and trying to find a small bit of code that I can use with If Fnd Is Nothing Then

Have bee using If Fnd Is Nothing Then Exit Sub this was helpful while building and testing the worksheet but now that it is being utilized I want to change it so if Fnd is Nothing then move to a certain line. Here is small portion of the code

Sheets("Call Times All Teams").Select
Range("a2.a75").Select
Set Fnd = Columns(1).Find(What:="Jacqueline Bishop", After:=ActiveCell, LookIn:=xlFormulas, _
Lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Fnd Is Nothing Then Exit Sub
Sheets("Lost Times Juliya").Range("I14").Value = Fnd.Offset(0, 15).Value
Sheets("Lost Times Juliya").Range("K14").Value = Fnd.Offset(0, 7).Value
Sheets("Call Times All Teams").Select
Range("a2.a75").Select
Set Fnd = Columns(1).Find(What:="Debra Caldwell", After:=ActiveCell, LookIn:=xlFormulas, _
Lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Fnd Is Nothing Then Exit Sub
Sheets("Lost Times Juliya").Range("I15").Value = Fnd.Offset(0, 15).Value
Sheets("Lost Times Juliya").Range("K15").Value = Fnd.Offset(0, 7).Value


What I would like to do is if it can't find Jacqueline Bishop then it just moves to the line with Debra Caldwell and looks for her. The list of names are all located on the Call Times All Teams worksheet. So if it can't find Jacqueline then it would move to Debra and if it can't find Debra it moves to the next person on the list and so on.

Any help would be greatly appreciated. Thanks
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Sheets("Call Times All Teams").Select
Range("a2.a75").Select
Set Fnd = Columns(1).Find(What:="Jacqueline Bishop", After:=ActiveCell, LookIn:=xlFormulas, _
Lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Fnd Is Nothing Then Exit Sub
Sheets("Lost Times Juliya").Range("I14").Value = Fnd.Offset(0, 15).Value
Sheets("Lost Times Juliya").Range("K14").Value = Fnd.Offset(0, 7).Value
Sheets("Call Times All Teams").Select
Range("a2.a75").Select

Set Fnd = Columns(1).Find(What:="Debra Caldwell", After:=ActiveCell, LookIn:=xlFormulas, _
Lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Fnd Is Nothing Then Exit Sub
Sheets("Lost Times Juliya").Range("I15").Value = Fnd.Offset(0, 15).Value
Sheets("Lost Times Juliya").Range("K15").Value = Fnd.Offset(0, 7).Value

What I would like to do is if it can't find Jacqueline Bishop then it just moves to the line with Debra Caldwell and looks for her.
Try replacing what I highlighted in red above with this...
Code:
[table="width: 500"]
[tr]
	[td]If Not Fnd Is Nothing Then
  Sheets("Lost Times Juliya").Range("I14").Value = Fnd.Offset(0, 15).Value
  Sheets("Lost Times Juliya").Range("K14").Value = Fnd.Offset(0, 7).Value
  Sheets("Call Times All Teams").Select
  Range("a2.a75").Select
End If[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0
Try it like this
Code:
If Not Fnd Is Nothing Then
   Sheets("Lost Times Juliya").Range("I14").Value = Fnd.Offset(0, 15).Value
   Sheets("Lost Times Juliya").Range("K14").Value = Fnd.Offset(0, 7).Value
   Sheets("Call Times All Teams").Select
   Range("a2.a75").Select
End If
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top