Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I require user to fill cell1 also if he/she fille cell2?

Status
Not open for further replies.

mimitan

Technical User
Dec 17, 2004
34
Greeting to All,

Question 1)
I am trying to implement something like this: I have in Column A as Date and Column B as Quantity.

Date Qty
07/25/05 1

if a user enter a number in the Qty field and go to different cell and left the Date blank, a message should pop up and ask the user to enter a date for that Qty before he/she can move on.

Questions 2: Is there something I can do to show a reminder message to users to log their name in Cell C1, for example, anytime they save the sheet and C1 is blank?

Thanks for helps
 


Hi,

Take a look at the Worksheet_Change event. If the user enters a value in column B AND the corresponding cell in column A is empty, then...

Skip,
[sub]
[glasses] [red]Be advised:[/red]We know Newton's 3 Laws. But did you hear about the [red]FOURTH???[/red]
Only ONE fig per cookie![tongue][/sub]
 
1.On the
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

End Sub
You can check the cells for entries and pop up message boxes etc...

2. You should be able to capture the OnWorkbook Close event. Then you can check for cell C1 value. Other way is again in the above routine, if worksheet changes make sure user enters name in C1 (you can also get excel to enter the windows user ID login name on Worksheet Open call.



Robert Cumming
 
I am sorry. I tried but was not successful. I have so little knowledge on VBA, and was unable to get the syntax correctly. Could you please show me more detail. Thanks!
 


Exactly WHAT did you enter and exactly WHERE?

Skip,
[sub]
[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue][/sub]
 
Hi Skip, I think I got this working and this is what I have:

Private Sub Worksheet_Change(ByVal Target As Range)

If (Target.Column = 2) Then
If (Target.Value > 0) Then
If (Cells((Target.Row), 1) = "") Then
MsgBox "Input Date"
End If
End If
End If

End Sub

It is working but I am not sure this is a good way to put it. and How can I make it in a way that the user HAS to enter a date if not the message keeps poping up, and can not continue unless a date is enter next to it.
Thanks for your helps
 
Maybe you should try something like this:

In your Worksheet_Change subroutine replace MsgBox with InputBox like this

Code:
Dim x as Variant
...

Do
  x = InputBox("Enter date", "Date")
Loop While (x = False Or x = Empty)

If user submits without entering anything x will be equal empty, if user cancels x will be equal to false.
 
Of course you should also add to loop condition something like:
Code:
Do
  x = InputBox( "Enter date", "Date" )
Loop While (x = False Or x = Empty Or Not IsDate(x))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top