LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How to make it work for "WHOLE" workbook

On Apr 4, 2:35*pm, test wrote:
On Apr 3, 9:16*pm, jasontferrell wrote:

Use this one also, and add the same code to this subroutine.


Private Sub Workbook_BeforeClose(Cancel As Boolean)


Thanks alot Jason. That works.


One more help. Below is an extract from my requirement. The code seems
to be working fine but I do not want the below code to run if the
column E value is NULL (Blank). This should be a exceptional case
where the code should skip blank values in column E. Can you please
advise what could be changed in the below code to reflect this.

Let me know if any more information is needed from my side. I am
currently using excel 2003

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim MySheet As String, lastrow As Long
MySheet = "Sheet1"
lastrow = Sheets(MySheet).Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Sheets(MySheet).Range("E4:E" & lastrow)
For Each c In MyRange
Select Case UCase(c)
Case "FAIL", "OTHER"
If c.Offset(, 1).Value = "" Then
MsgBox "Invalid Comment at " & c.Offset(, 1).Address
Cancel = True
Exit For
End If
Case "SUCCESS"
If c.Offset(, 1).Value = "" Then
Cancel = False
End If
Case Else
MsgBox "Invalid value in " & c.Address
Cancel = True
Exit For
End Select
Next
End Sub
 
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
How do you make the INFO("directory") function work? TimR[_2_] Excel Worksheet Functions 1 November 13th 09 01:20 AM
I can't make the "unhide column" work in 2007 Excell Pearce Henry New Users to Excel 3 October 4th 09 07:44 PM
If changed array formula reduce ""\""\""\ - signs to #Missing, will it make ... Maria J-son[_2_] Excel Programming 2 March 5th 06 12:20 PM
Can't make Excel "if" Formula work Janie Ellen Excel Worksheet Functions 1 November 8th 05 04:47 PM
Why doesn't "Workbook.Range("myrange").value" work? Brad Patterson Excel Programming 0 July 9th 03 01:24 AM


All times are GMT +1. The time now is 06:54 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"