george hart
Board Regular
- Joined
- Dec 4, 2008
- Messages
- 241
Help...
The code below works fine, yet when the condition If Range("X" & X).Value = "Short" And Range("Y" & X).Value = "" Then _
MsgBox "You must enter the responsible owner for all shortforms prior exporting." Is true I dont want the following code to run. I want it to exit sub. If it's not true then I want it to run. Any ideas???????
Dim NewFileName
Dim X As Variant
For X = 6 To 33
Application.DisplayAlerts = False
Application.ScreenUpdating = False
If Range("X" & X).Value = "Short" And Range("Y" & X).Value = "" Then _
MsgBox "You must enter the responsible owner for all shortforms prior exporting."
Next
Sheets("All Trains").Select
Sheets("All Trains").Copy
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Rows("47:54").Select
Selection.Delete Shift:=xlUp
Range("B1").Select
NewFileName = "O:\_First Performance\Shortforms\Short Form Regime\Daily Reports\FW30 Daily Formation File-" & _
Format$(Range("C3").Value, "ddmmmyy") & ".xls"
For Each ws In Worksheets
ActiveSheet.Name = Format(Range("C3").Value, "yymmdd")
Next
ActiveWorkbook.SaveAs Filename:=NewFileName
ActiveWorkbook.Close
MsgBox "FGW30 Daily Formation File complete for the" & " - " & Range("C3")
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Many thanks in advance...
The code below works fine, yet when the condition If Range("X" & X).Value = "Short" And Range("Y" & X).Value = "" Then _
MsgBox "You must enter the responsible owner for all shortforms prior exporting." Is true I dont want the following code to run. I want it to exit sub. If it's not true then I want it to run. Any ideas???????
Dim NewFileName
Dim X As Variant
For X = 6 To 33
Application.DisplayAlerts = False
Application.ScreenUpdating = False
If Range("X" & X).Value = "Short" And Range("Y" & X).Value = "" Then _
MsgBox "You must enter the responsible owner for all shortforms prior exporting."
Next
Sheets("All Trains").Select
Sheets("All Trains").Copy
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Rows("47:54").Select
Selection.Delete Shift:=xlUp
Range("B1").Select
NewFileName = "O:\_First Performance\Shortforms\Short Form Regime\Daily Reports\FW30 Daily Formation File-" & _
Format$(Range("C3").Value, "ddmmmyy") & ".xls"
For Each ws In Worksheets
ActiveSheet.Name = Format(Range("C3").Value, "yymmdd")
Next
ActiveWorkbook.SaveAs Filename:=NewFileName
ActiveWorkbook.Close
MsgBox "FGW30 Daily Formation File complete for the" & " - " & Range("C3")
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Many thanks in advance...