Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I make a cell mandatory?
Hello, I searched the forums and were able to find similar things but canno make it work for the action that I need. I am trying to make B1 a mandatory cell if user puts data in A1. So i there is data in A1 and B1 is empty, an error message should b displayed on Save. I am sure it is not very hard but I am not much o an Excel programmer. Any help will be greatly appreciated... Thanks in advance.. -- alch ----------------------------------------------------------------------- alche's Profile: http://www.hightechtalks.com/m90 View this thread: http://www.hightechtalks.com/t235327 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I make a cell mandatory?
Add this code to the ThisWorkbook code module:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) With Worksheets("Sheet1") If .Range("A1").Value < "" And .Range("B1").Value = "" Then MsgBox "Mandatory cell not filled. No Save" Cancel = True End If End With End Sub -- Rob van Gelder - http://www.vangelder.co.nz/ "alche" wrote in message ... Hello, I searched the forums and were able to find similar things but cannot make it work for the action that I need. I am trying to make B1 a mandatory cell if user puts data in A1. So if there is data in A1 and B1 is empty, an error message should be displayed on Save. I am sure it is not very hard but I am not much of an Excel programmer. Any help will be greatly appreciated... Thanks in advance... -- alche ------------------------------------------------------------------------ alche's Profile: http://www.hightechtalks.com/m900 View this thread: http://www.hightechtalks.com/t2353270 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I make a cell mandatory?
Why wait until the user tries to do a save?
Why not just use an adjacent cell and give the user a message: =if(and(a1<"",b1=""),"Please enter a value in B1","") As a user, I think I would appreciate the immediate feedback. alche wrote: Hello, I searched the forums and were able to find similar things but cannot make it work for the action that I need. I am trying to make B1 a mandatory cell if user puts data in A1. So if there is data in A1 and B1 is empty, an error message should be displayed on Save. I am sure it is not very hard but I am not much of an Excel programmer. Any help will be greatly appreciated... Thanks in advance... -- alche ------------------------------------------------------------------------ alche's Profile: http://www.hightechtalks.com/m900 View this thread: http://www.hightechtalks.com/t2353270 -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can I make a cell mandatory?
Thank you very much! I inserted both and it is even better than thought : -- alch ----------------------------------------------------------------------- alche's Profile: http://www.hightechtalks.com/m90 View this thread: http://www.hightechtalks.com/t235327 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I make a specific cell mandatory? | Excel Discussion (Misc queries) | |||
How can I make a cell mandatory? | Excel Discussion (Misc queries) | |||
How can I make a cell mandatory and only accept a Y or N? | Excel Worksheet Functions | |||
Can I make cell completion mandatory in excel? | Excel Discussion (Misc queries) | |||
Make a cell mandatory before sending | Excel Programming |