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: 10
Default Prevent closing if values do not match

Hello,

My goal is to prevent the workbook from closing if there is not a value in
Row 4, Column 4 when Row 4, Column 5 does have a value. This condition would
apply for rows 4 to 454.

I think I'm headed in the right direction, but I must be missing something...

So far I have:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

For i = 4 To 454

Set hours = Worksheets("Test").Cells(i, 5)
Set task = Worksheets("Test").Cells(i, 4)

If hours = 0 Then
Cancel = False
Else
If task = 0 Then
Cancel = True
End If
End If

Next i

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
Prevent closing userform Gert-Jan[_2_] Excel Programming 1 October 8th 06 03:59 PM
Prevent closing userform Gert-Jan[_2_] Excel Programming 0 October 8th 06 03:48 PM
Prevent DialogBox closing Patrick Simonds Excel Programming 3 October 5th 05 06:16 PM
Prevent workbook closing... Dave Excel Programming 4 October 25th 04 06:42 PM
API to prevent closing Excel Peter Dao Excel Programming 1 August 12th 03 01:35 AM


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