making cell manditory??

kimberly13

New Member
Joined
Apr 11, 2003
Messages
35
I am working on a biding program using valiation, dialog boxes and such. I was wondering if there was a way to make certain that they have to put a value other that zero or none in a cell before moving on to the next step??
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Yes Kimberly, you can. The following example will not allow you to select cell C6 until something has been entered in cell B4.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$C$6" Then
If IsEmpty([B4]) Then
Beep
MsgBox "You must enter data in B4 before selecting this cell"
[B4].Activate
End If
End If
End Sub

This code must be placed in the worksheet's event code module. To do this, right-click on the worksheet tab, select View Code, and paste this code into the Code pane.
 
Upvote 0
Damon,

could this been done with dialog boxes??? Right now the dialog box opens with either "none" or "0" in each box. right now have drop downs to fill in the needed information.
 
Upvote 0
Hi again Kimberly,

I assume you are referring to textboxes on a custom userform? If so, here is an example that prevents the entry of date in TextBox2 until TextBox1 contains a value other than 0 or "none".

Private Sub TextBox2_Change()
If TextBox2 = 0 Or TextBox2 = "none" Then Exit Sub
If TextBox1 = 0 Or TextBox1 = "none" Then
EnableEvents = False
TextBox2 = 0
EnableEvents = True
MsgBox "can't enter date until after field 1 entry"
TextBox1.SetFocus
End If
End Sub

I hope this helps.

Damon
 
Upvote 0
Thanks Damon!! I will work with this over the weekend and let you know!!

One day maybe I too will be really good at excel!?!?!?!? OR I will just have many notebooks full of notes!! :)
 
Upvote 0

Forum statistics

Threads
1,221,695
Messages
6,161,361
Members
451,699
Latest member
sfairbro

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