Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
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
How do I make a specific cell mandatory? soday Excel Discussion (Misc queries) 2 April 30th 09 04:41 PM
How can I make a cell mandatory? [email protected] Excel Discussion (Misc queries) 3 February 6th 06 11:01 PM
How can I make a cell mandatory and only accept a Y or N? Vicki Excel Worksheet Functions 1 June 23rd 05 07:23 PM
Can I make cell completion mandatory in excel? Peter Green Excel Discussion (Misc queries) 3 December 23rd 04 03:29 PM
Make a cell mandatory before sending dmposey Excel Programming 4 November 3rd 04 04:38 AM


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