Is there a way to build into a macro a check to see if preset conditions are met and produce an error message if those conditions are not met?
Here is the condition as if it were a formula in Excel:
=IF(COUNTIF(Output!E2:E101,5)<19,"do macro","post an error message with text I can edit")
Here is the existing code for the macro:
Sheets("Output").Select
Range("D2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\nmagnuso\Desktop\Book4.csv", FileFormat:=xlCSV, _
CreateBackup:=False
fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="CSV Files(*.csv), *.csv")
If fileSaveName <> False Then
MsgBox "Save as " & fileSaveName
End If
ActiveWorkbook.SaveAs Filename:=fileSaveName, FileFormat:=xlCSV
End Sub
Thanks for your help.
magnusver
Here is the condition as if it were a formula in Excel:
=IF(COUNTIF(Output!E2:E101,5)<19,"do macro","post an error message with text I can edit")
Here is the existing code for the macro:
Sheets("Output").Select
Range("D2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\nmagnuso\Desktop\Book4.csv", FileFormat:=xlCSV, _
CreateBackup:=False
fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="CSV Files(*.csv), *.csv")
If fileSaveName <> False Then
MsgBox "Save as " & fileSaveName
End If
ActiveWorkbook.SaveAs Filename:=fileSaveName, FileFormat:=xlCSV
End Sub
Thanks for your help.
magnusver