Hello. I am looking for a macro code that I can use to look down all of column "A" and check for any cell that has the word "Error". If "Error" is found, I want to stop running the remainder of the macro code and generate a pop up box warning of error. It would be awesome if there was a continue and end button on this popup box.
If the continue button was clicked it would continue running the remainder of the macro regardless of errors being present. If the end button was clicked it would close the box and return back to sheet. Below is the code I want to use depending on the if/then statement.
If the continue button was clicked it would continue running the remainder of the macro regardless of errors being present. If the end button was clicked it would close the box and return back to sheet. Below is the code I want to use depending on the if/then statement.
Code:
Sub CreateUserInitiatedLoadCSV()Dim wbNew As Workbook
Dim wbSrc As Workbook
Dim SaveToDirectory As String
Dim CurrentWorkbook As String
Dim CurrentFormat As Long
Dim nmary As Variant, sh1 As Worksheet, sh2 As Worksheet, i As Long, rng As Range
Set wbSrc = ThisWorkbook
Set sh1 = wbSrc.ActiveSheet
nmary = Array("ODS ID#", "Counterparty", "Moodys", "S&P", "Fitch", "Country of Domicile", "Ult. Parent Country of Domicile")
Set wbNew = Workbooks.Add(xlWBATWorksheet)
Set sh2 = wbNew.Sheets(1)
For i = LBound(nmary) To UBound(nmary)
Set rng = sh1.Rows(4).Find(nmary(i), , xlValues).EntireColumn
rng.Copy sh2.Cells(1, i + 1)
sh2.Columns.AutoFit
Next
' Store current details for the workbook
CurrentWorkbook = ThisWorkbook.FullName
CurrentFormat = ThisWorkbook.FileFormat
SaveToDirectory = "C:\Users\Zach\Desktop\"
wbNew.SaveAs Filename:=SaveToDirectory & "CounterPartyUIL" & "-" & Format(Date, "MM-YYYY") & ".csv", FileFormat:=xlCSV
wbNew.Close savechanges:=False
Application.DisplayAlerts = False
ThisWorkbook.SaveAs Filename:=CurrentWorkbook, FileFormat:=CurrentFormat
Application.DisplayAlerts = True
End Sub