Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
save on condition
hi,
the first cells the must be checked are E10 and F10. thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
lookup with multiple condition, but one condition to satisfy is en | Excel Worksheet Functions | |||
Don't save file if condition is met | Excel Programming | |||
Save Condition | Excel Worksheet Functions | |||
Save If Condition is true | Excel Programming | |||
Code to Test Condition and Save Record to Excel | Excel Programming |