Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Why Wont This Work? VBA Help Needed!


Why Does This Not Work Properly?

The Sub CommandButton2_Click() code ensures that specific data has bee
entered before allowing the user to continue,
If not the Sub Exits, If they have entered the needed data then I wan
to run the
SaveLock Sub.
However it will work up to the copy sheet to a new workbook part bu
then stops.
Why?

Should I put something different to

Call Savelock at the Else part of the first code?




Private Sub CommandButton2_Click()
Dim rng As Range

Set rng = Range("E6,E16")

If Application.CountA(rng) < 2 Then
MsgBox "Please Complete At Least The Following" & Chr(13) & Chr(13)
"Last Collection Call Date." & Chr(13) & "Lockout Prepared By."
vbInformation, "IMPORTANT!"
Exit Sub

Else
Call SaveLock

End If

End Sub




Private Sub SaveLock()
Dim LockOut

LockOut = MsgBox("Are You Sure You Wish To Create Your Lockout Reques
At This Time?", vbYesNo, "DAILY DRAT")
If LockOut = vbNo Then End

Sheets("Lockout").Select
Sheets("Lockout").Copy
ActiveWindow.DisplayHeadings = False

Dim fn As Variant
fn
Application.GetSaveAsFilename(InitialFileName:=Wor ksheets("Lockout").Range("J2").Value
FileFilter:="Excel Files (*.xls), *.xls", _
Title:="Save This Lockout Request Into Your Lockouts Folder! Do No
Change The File Name Shown!")
If TypeName(fn) = "Boolean" Then
ActiveWorkbook.Close SaveChanges:=False
Sheets("Lock6").Select
MsgBox "Your Lockout Request WAS NOT Saved", vbOKOnly, "SAV
CANCELLED!"
Exit Sub
End If
ActiveWorkbook.SaveAs fn
ActiveWorkbook.Close SaveChanges:=False
ActiveWorkbook.Sheets("Dispatch").Select
MsgBox "Your Lockout Request Has Been Saved And Closed." & Chr(13)
"Please Email To Your District Manager For Processing!"
End Sub


I hope someone can help me with this.

Thanks

Celtic_Avenger
:confused

--
Celtic_Avenge
-----------------------------------------------------------------------
Celtic_Avenger's Profile: http://www.excelforum.com/member.php...fo&userid=1410
View this thread: http://www.excelforum.com/showthread.php?threadid=26138

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default Why Wont This Work? VBA Help Needed!

However it will work up to the copy sheet to a new workbook part but
then stops.


The code stops executing or the expected result is not seen in Excel?

Arrange windows so you can see your code and the Excel UI (the workbooks) at
the same time. Put a breakpoint at the line Sheets("Lockout").Copy (put your
cursor on the line and press F9). Now run the code. When code execution
stops, press F8. In the Excel UI, see if a new workbook was created with the
copied sheet in it. Continue to step thru (F8) or run the code, checking to
see that what you expect is happening. or if not why not.

"Celtic_Avenger" wrote in
message ...

Why Does This Not Work Properly?

The Sub CommandButton2_Click() code ensures that specific data has been
entered before allowing the user to continue,
If not the Sub Exits, If they have entered the needed data then I want
to run the
SaveLock Sub.
However it will work up to the copy sheet to a new workbook part but
then stops.
Why?

Should I put something different to

Call Savelock at the Else part of the first code?




Private Sub CommandButton2_Click()
Dim rng As Range

Set rng = Range("E6,E16")

If Application.CountA(rng) < 2 Then
MsgBox "Please Complete At Least The Following" & Chr(13) & Chr(13) &
"Last Collection Call Date." & Chr(13) & "Lockout Prepared By.",
vbInformation, "IMPORTANT!"
Exit Sub

Else
Call SaveLock

End If

End Sub




Private Sub SaveLock()
Dim LockOut

LockOut = MsgBox("Are You Sure You Wish To Create Your Lockout Request
At This Time?", vbYesNo, "DAILY DRAT")
If LockOut = vbNo Then End

Sheets("Lockout").Select
Sheets("Lockout").Copy
ActiveWindow.DisplayHeadings = False

Dim fn As Variant
fn =

Application.GetSaveAsFilename(InitialFileName:=Wor ksheets("Lockout").Range("
J2").Value,
FileFilter:="Excel Files (*.xls), *.xls", _
Title:="Save This Lockout Request Into Your Lockouts Folder! Do Not
Change The File Name Shown!")
If TypeName(fn) = "Boolean" Then
ActiveWorkbook.Close SaveChanges:=False
Sheets("Lock6").Select
MsgBox "Your Lockout Request WAS NOT Saved", vbOKOnly, "SAVE
CANCELLED!"
Exit Sub
End If
ActiveWorkbook.SaveAs fn
ActiveWorkbook.Close SaveChanges:=False
ActiveWorkbook.Sheets("Dispatch").Select
MsgBox "Your Lockout Request Has Been Saved And Closed." & Chr(13) &
"Please Email To Your District Manager For Processing!"
End Sub


I hope someone can help me with this.

Thanks

Celtic_Avenger



--
Celtic_Avenger
------------------------------------------------------------------------
Celtic_Avenger's Profile:

http://www.excelforum.com/member.php...o&userid=14101
View this thread: http://www.excelforum.com/showthread...hreadid=261382



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
IF sum is GreaterThan 0... why wont this work!? Tan. Excel Worksheet Functions 3 January 18th 06 09:36 PM
Control + C wont work WREFORD Excel Discussion (Misc queries) 3 August 25th 05 04:44 PM
Dialogue Box Wont Dissapear In Time: VBA Help Needed Celtic_Avenger[_40_] Excel Programming 0 September 18th 04 08:04 PM
Dialogue Box Wont Dissapear In Time: VBA Help Needed Celtic_Avenger[_39_] Excel Programming 1 September 18th 04 06:49 PM
Sumproduct wont work Mycotopian[_3_] Excel Programming 2 August 5th 04 08:06 PM


All times are GMT +1. The time now is 03:30 AM.

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

About Us

"It's about Microsoft Excel"