Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default save on condition

hi all,

i need to creat an excel that prevent the user to save the file unless
he enters data on certain cells, for example
if the user enters data on cell E10 he must also enter data on cell
F10, if he doesnt do that he cant save the file and a msgbox appears
that ask him to enter the missing data.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default save on condition

Hi Guye,

Try:

'=============
Private Sub Workbook_BeforeSave( _
ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim SH As Worksheet

Set SH = Me.Sheets("Sheet2") '<<=== CHANGE

With SH
If Not IsEmpty(.Range("E10")) Then
If IsEmpty(Range("F10")) Then
Cancel = True
MsgBox ("Your message")
End If
End If
End With

End Sub
'<<=============

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module:

Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman

"Guye" wrote in message
oups.com...
hi all,

i need to creat an excel that prevent the user to save the file unless
he enters data on certain cells, for example
if the user enters data on cell E10 he must also enter data on cell
F10, if he doesnt do that he cant save the file and a msgbox appears
that ask him to enter the missing data.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default save on condition

Hello
Place this code into Thisworkbook and amend accordingly:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
With Worksheets("Sheet1")
If .Range("E10").Value < "" And .Range("F10").Value < "" Then
Cancel = False
Else
Cancel = True
MsgBox "Please note input is required into both cells E10 and F10 on sheet
SHEET1"
End If
End With
End Sub

HTH
Cordially
Pascal

"Guye" a écrit dans le message de news:
...
hi all,

i need to creat an excel that prevent the user to save the file unless
he enters data on certain cells, for example
if the user enters data on cell E10 he must also enter data on cell
F10, if he doesnt do that he cant save the file and a msgbox appears
that ask him to enter the missing data.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default save on condition

hi,
thanks for the solutions.
but i need the code to work on the 2 worksheet of the file.
and to check it not only on the cells mentioned, but on cells G10 as a
pair H10 and so forth, for all rows.
if you can help me it would bw wonderful,
and thanks,
Guy

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default save on condition

hi,
to be more accurate, it must apply to the 26 first columns and 1000
rows on each work sheet.

thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default save on condition

hi,
the first cells the must be checked are E10 and F10.

thanks

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
lookup with multiple condition, but one condition to satisfy is en Eddy Stan Excel Worksheet Functions 2 October 27th 07 02:06 PM
Don't save file if condition is met Andre Croteau Excel Programming 8 September 3rd 06 02:48 AM
Save Condition GarToms Excel Worksheet Functions 0 May 2nd 06 03:33 PM
Save If Condition is true igorek Excel Programming 2 July 12th 05 11:19 PM
Code to Test Condition and Save Record to Excel Ken Hudson Excel Programming 0 May 25th 05 05:32 PM


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