Which data have been entered into a cell ?

H

hglamy

Hello there,

I need to react to the data that a user may enter into
certain cells (XL XP).

How can I programmatically catch the entry that has
been made ?

Help greatly appreciated.

Kind regards,

H.G. Lamy
 
B

Bob Phillips

HG,

You need the Worksheet_Change event.

You test for what has been entered by testing the Target argument. For
instance, if you want to react to all changes in column N, use

If Target.Column = 14 Then

If you want to test for cells B5:G7 say, use

If (Not Intersect(Target,Range("B5:G7")) Is Nothing) Then

and then do your stuff.

As this is worksheet code, it goes into the worksheet code module.


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
C

Chip Pearson

Use the Change event procedure in the Sheet's code module. E.g.,

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case "$A$1", "$B$2", "$C$3"
MsgBox "You changed one of these cells"
Case Else
MsgBox "You changed cell " & Target.Address
End Select
End Sub


--
Cordially,
Chip Pearson
Pearson Software Consulting, LLC
Microsoft MVP - Excel
www.cpearson.com (e-mail address removed)
 
H

hglamy

Thank you !

I had tried to work with the "Selection_Change" event,
but with "Worksheet_Change" you pointed me to the right direction !

Kind regards,

H.G. Lamy
 

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

Top