ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Make a cell required (https://www.excelbanter.com/excel-programming/335211-make-cell-required.html)

cpointcc

Make a cell required
 

I want to make a cell that has a drop down list required. eg.: if cel
a5 < 0, the drop down option in cell b5 must be chosen, the cell canno
be blank.

Any suggestions

--
cpointc
-----------------------------------------------------------------------
cpointcc's Profile: http://www.excelforum.com/member.php...fo&userid=2547
View this thread: http://www.excelforum.com/showthread.php?threadid=38916


theDude[_16_]

Make a cell required
 

You can use event macros in Excel to ensure a cell has an entry...

This macro will check to see if an entry exists in cell B5 if cell A
is less than zero EVERY TIME a change is made to the worksheet. I
both conditions are true, it alerts the user and then selects cell B
for the user to make an entry. Copy it to the code page of th
worksheet that needs the required entry in cell B5:

Code
-------------------
Private Sub Worksheet_Change(ByVal Target As Range)
' Check for value less than 0 in cell A5 & blank cell B5
' If both are true, alert user and select B5...
If Cells(5, 1) < 0 And Cells(5, 2) = "" Then
MsgBox "You must select a value for cell B5."
Cells(5, 2).Activate
End If
End Su
-------------------


Additionally, this macro will check to see if an entry exists in cel
B5 if cell A5 is less than zero whenever the user tries to CLOSE TH
WORKBOOK. If both conditions are true, it prevents the workbook fro
closing, alerts the user and then selects cell B5 for the user to mak
an entry. Copy it to the code page of the This Workbook object in th
file:

Code
-------------------
Private Sub Workbook_BeforeClose(Cancel As Boolean)
' Check for value less than 0 in cell A5 & blank cell B5
' If both are true, alert user and select B5...
If Cells(5, 1).Value < 0 And Cells(5, 2).Value = "" Then
Cancel = True
MsgBox "You must select a value for cell B5."
Cells(5, 2).Activate
End If
End Su
-------------------

Hope this helps,
theDud

--
theDud
-----------------------------------------------------------------------
theDude's Profile: http://www.excelforum.com/member.php...fo&userid=1655
View this thread: http://www.excelforum.com/showthread.php?threadid=38916



All times are GMT +1. The time now is 03:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com