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: 852
Default Before_Close macro, How to...?

I am for sure missing some fundamental concept on how to make a Before_Close macro work.

I have tried several combinations of examples from google searches and none will check A1 to A200 for contents, I close the workbook, and it just closes with no action taken.

These are both in the ThisWorkbook module.

I can run the non-event code from the sheet "ABC" and it works just as I need.

I've tried calling the non-event from the Before_Close and it too does not respond.

Thanks,
Howard

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not Me.Saved Then

If WorksheetFunction.CountA(Sheets("ABC").Range("A1:A 200")) < 200 Then

Dim Reply As VbMsgBoxResult
Reply = MsgBox("Cells A1 to A200" _
& vbCr & "must have values" _
& vbCr & "before the workbook is closed", _
vbOKOnly + vbExclamation, "Two Hundred Empty!")

Else
End If
End If
'Cancel = True
End Sub


Sub MyCheckOnColumnA()

If WorksheetFunction.CountA(Sheets("ABC").Range("A1:A 200")) < 200 Then
Dim Reply As VbMsgBoxResult
Reply = MsgBox("Cells A1 to A200" _
& vbCr & "must have values" _
& vbCr & "before the workbook is closed", _
vbOKOnly + vbExclamation, "Two Hundred Empty!")

Else
End If

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
Wierd one concerning Before_Close and OnTime Antonio Excel Discussion (Misc queries) 14 June 9th 06 05:33 PM
Difference between before_close and auto_close phcvergouwe Excel Programming 8 May 23rd 06 07:49 AM
Workbook Before_Close question Stuart[_5_] Excel Programming 2 June 28th 04 07:42 PM
Before_Close problem Roberto[_4_] Excel Programming 4 November 15th 03 10:49 AM
Auto_Open & Before_Close John Wilson Excel Programming 0 August 6th 03 09:04 PM


All times are GMT +1. The time now is 10:32 PM.

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"