Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Checking a cell

Is it possible to have VB continuously check a cell to
see if the value has changed?

JPica
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Checking a cell

That's the opposite,
when something change on the sheet (or in the workbook) you checj , then, if
it's your cell.

for any sheet, you will place your code on the ThisWorbook Excel Object's
code
(and no other module else !)
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
' your code
End Sub


for only one sheet, you can place the code on the shhet's code
(and no other module else)
Private Sub Worksheet_Change(ByVal Target As Range)
' your code
End Sub

IN BOTH CASES, Target is the changed range
The code could, for example be:

if not (Application.Intersect(Target, Range("A1")) Is Nothing) then
'what I want for this cell
end if
' if you try it from workbook (not sheet) think about also testing the
active sheet name !
for example add a
if (activesheet.name = Sheet1.name) and (...) then
end if
or for the range use the: sheet1.range("A1") (and not the range alone)

For more details, take a look on events' helps
(this is classical and quick to be found on internet, when looking for it)

David.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Checking a cell

JPica,

You can do it using a worksheet event. Copy the code below, right click on
the worksheet tab, select 'View Code', then paste the code into the window
that appears. The sample code will monitor cell A1. Change as needed.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then MsgBox "Cell A1 changed!"
End Sub


"JPica" wrote in message
...
Is it possible to have VB continuously check a cell to
see if the value has changed?

JPica



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Checking a cell

Hi

Read Chip Pearson's site about Events
http://www.cpearson.com/excel/events.htm


This example is to test A1

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
MsgBox "You changed cell A1"
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"JPica" wrote in message ...
Is it possible to have VB continuously check a cell to
see if the value has changed?

JPica



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Checking a cell

JPica,

I should have also said that if the cell that you want to monitor contains a
formula, you will need to have a second cell that contains just the current
value of the cell, and then use the calculate event to compare the cell with
the formula with the value cell, as below.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Calculate()
If Range("A1").Value < Range("A2").Value Then
MsgBox "Cell A1 changed!"
Application.EnableEvents = False
Range("A2").Value = Range("A1").Value
Application.EnableEvents = True
End If


"JPica" wrote in message
...
Is it possible to have VB continuously check a cell to
see if the value has changed?

JPica



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for a particular string in a cell Christopher Naveen[_2_] Excel Worksheet Functions 3 April 15th 08 12:54 PM
Spell Checking with checking cell notes jfitzpat Excel Discussion (Misc queries) 0 August 8th 07 10:26 PM
Checking cell for Number Lee New Users to Excel 2 October 11th 05 09:23 PM
cell checking Lee New Users to Excel 5 August 25th 05 08:43 PM
Checking a cell Robert Couchman[_4_] Excel Programming 5 February 18th 04 01:51 PM


All times are GMT +1. The time now is 08:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"