Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
simplify my codes
This is easier to read maybe?
Sub SaveEntry() With Workbooks("Declaration Pro.xls") If .Worksheets("CPC").Range("AE3").Value < "Saved" _ And .Worksheets("Front").Range("L71").Value "0" Then If MsgBox("Do you want to Save this Entry", vbYesNo, "Save Entry") = vbYes Then SaveAsFile End With End Sub Sub SaveAsFile() Dim mWB As Workbook If MsgBox("Save Entry?", vbYesNo, "Save Entry") = vbYes Then Set mWB = Workbooks.Add(1) Application.DisplayAlerts = False Application.Dialogs(xlDialogSaveAs).Show ("myfile.xls") mWB.Save mWB.Close Application.DisplayAlerts = True End If End Sub -- Cheers Nigel "pape93gyal" wrote in message ... Can someone help me simplify my codes please Sub SaveEntry() If Workbooks("Declaration Pro.xls").Worksheets("CPC").Range("AE3").Value < "Saved" And Workbooks("Declaration Pro.xls").Worksheets("Front").Range("L71").Value "0" Then SaveFil = MsgBox("Do you want to Save this Entry", vbYesNo, "Save Entry") If SaveFil = vbYes Then SaveAsFile End If End If End Sub Sub SaveAsFile() Dim FName As Variant Dim mWB As Workbook SaveFile = MsgBox("Save Entry?", vbYesNo, "Save Entry") FName = "myfile.xls" If SaveFile = vbYes Then Set mWB = Workbooks.Add(1) Application.DisplayAlerts = False Application.Dialogs(xlDialogSaveAs).Show (FName) file = mWB.Name Workbooks(file).Activate 'save file Workbooks(file).Save Workbooks(file).Close Else 'user cancelled 'do nothing End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
A way to simplify this please | Excel Programming | |||
please help simplify | Excel Programming | |||
please help simplify | Excel Programming | |||
please help simplify | Excel Programming | |||
Simplify | Excel Programming |