Changing an If then statement

bradyj7

Board Regular
Joined
Mar 2, 2011
Messages
106
Hi there,

The code below looks for the text 'Journey Start Event' in column E and if it cannot find it, it exits the routine.

Code:
Dim myCell1 As Range, _
    found   As Range
LastRow2 = Range("E" & Rows.Count).End(xlUp).Row
Set myCell1 = Range("E" & LastRow2)
Set found = Columns("E").Find(What:="Journey Start Event", LookIn:=xlValues, LookAt:=xlPart)
    If found Is Nothing Then Exit Sub

My questions is how do I change the if then statement to save the file to a folder before exiting the routine.

This is folder I want to save it to

Code:
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:="C:\Bad data\" & ActiveWorkbook.Name

thank you
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Try

Code:
Dim myCell1 As Range, _
    found   As Range
LastRow2 = Range("E" & Rows.Count).End(xlUp).Row
Set myCell1 = Range("E" & LastRow2)
Set found = Columns("E").Find(What:="Journey Start Event", LookIn:=xlValues, LookAt:=xlPart)
If found Is Nothing Then
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:="C:\Bad data\" & ActiveWorkbook.Name
    Application.DisplayAlerts = True
    Exit Sub
End If
 
Upvote 0
Untested, but it should be something along the lines of
Code:
If found Is Nothing Then
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:="C:\Bad data\" & ActiveWorkbook.Name
    Application.DisplayAlerts = True
    Exit Sub
End If
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,147
Members
452,891
Latest member
JUSTOUTOFMYREACH

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