Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A way to simplify this please Larry Empey[_2_] Excel Programming 3 July 1st 06 01:04 AM
please help simplify acarril[_11_] Excel Programming 1 September 27th 04 04:45 PM
please help simplify acarril[_10_] Excel Programming 1 September 21st 04 07:39 PM
please help simplify acarril[_9_] Excel Programming 1 September 21st 04 05:36 PM
Simplify Josh[_7_] Excel Programming 4 January 9th 04 12:16 AM


All times are GMT +1. The time now is 08:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"