mandatoru cell if another cell contains text

lfmemp

New Member
Joined
Dec 7, 2011
Messages
34
Hello everyone,

I need to make a cell mandatory to be filled out when another one contains text.

FOr example, if cell C3 contains some text, the code should then require cell D5 to be filled in.
A message box saying "Please fill out cell D5" should apear, after the cell C3 has been filled out. In this way, after C3 is filled, message appear and the user is forced to fill out D5.

Can anyone please help?

Thanks
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi,

Try,

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 
If Target.Address = "$C$3" Then
   MsgBox "Please fill out cell D5"
End If
End Sub

Jai
 
Upvote 0
Try this behind the relevant sheet (Alt+F11, double click sheet on left hand side, paste code on right hand side)

Code:
Option Explicit

Private bFlag As Boolean

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, [c3]) Is Nothing Then
    [D5].Select
    If Not bFlag Then MsgBox "You must now completed D5", vbCritical + vbSystemModal
    bFlag = True
End If

If Not Intersect(Target, [D5]) Is Nothing Then
    bFlag = False
End If
       
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If bFlag Then
            [D5].Select
End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,812
Members
449,048
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top