Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Is it possible to compel a user to enter a value in a cell?

  Asked By: Molly    Date: Oct 02    Category: MS Office    Views: 598
  

If Cells(Target.row,23) is nothing then
Cells(target.row,23).select
msgbox("You must enter a value in Column W")

?????

endif

Can I make it so that it both gives them the opportunity to enter
something in the cell, and if they don't, it keeps bothering them?

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Rosie Hughes     Answered On: Oct 02

The key word is "opportunity" here.

You need to define the rules exactly.

You already have some code that is very close to being runnable. What
happens when you run it? What does/doesn't it do that you want to do?

 
Answer #2    Answered By: Freya Brown     Answered On: Oct 02

So it takes them to the cell  and tells them to enter  it... but doesn't
stop them from moving on without entering data.

 
Answer #3    Answered By: Dep Tran     Answered On: Oct 02

I think I understand what you are wanting. It seems like a real pain
for a User that enters a value in column  W and then selects a new Row
with no intention of entering more data. Would it help too for your
code to verify other fields in the same row? If the whole row  is
empty then column W shouldn't matter, right?

Anyways, here is something I put together to fulfill what I think you
asked for.

Dim trg As Long

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If trg = 0 Then
trg = Target.Row
End If

'trg helps compare the new row selected with the previous row used
If (trg <> Target.Row And Cells(trg, 23) = "") Then
Cells(trg, 23).Select
MsgBox ("You must enter  a value in Column W")
Else
trg = Target.Row
End If

End Sub

 
Answer #4    Answered By: Cesara Fernandez     Answered On: Oct 02

That sounds like what your code will do. Is that what you want to do? If
so, where are you having trouble?

If not, then what do you actually want to do?

 




Tagged: