Make a cell required

  • Thread starter Thread starter cpointcc
  • Start date Start date
C

cpointcc

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top