Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 15
Default running some VBA code in response to data entered in a cell

hello again
Can anyone tell me if it is possible to trigger some VBA code when a number
entered in a particular cell on a worksheet is less than the number in
another cell?. I dont know if cells have events linked to them such as mouse
down etc

Thanks
Ian


  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 1,173
Default running some VBA code in response to data entered in a cell

Mantrid

You could use the worksheet_change event like so. Checks a value in A1 and
if below 10 it colours B1 red

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
If Target.Value < 10 Then
Target.Offset(0, 1).Interior.Color = RGB(255, 0, 0)
Else
Target.Offset(0, 1).Interior.ColorIndex = xlNone
End If
End If
End Sub

To install right-click the sheet tab and select 'view code...'

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
web:
www.nickhodge.co.uk
blog: www.nickhodge.co.uk/blog/

FREE UK OFFICE USER GROUP MEETING, MS READING, 27th APRIL 2007
www.officeusergroup.co.uk

"mantrid" wrote in message
...
hello again
Can anyone tell me if it is possible to trigger some VBA code when a
number
entered in a particular cell on a worksheet is less than the number in
another cell?. I dont know if cells have events linked to them such as
mouse
down etc

Thanks
Ian




  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 15
Default running some VBA code in response to data entered in a cell

Thanks again Nick
I think that is the kind of think I need. I will have a play and see if I
can get it to do what I need.
Ian


"Nick Hodge" wrote in message
...
Mantrid

You could use the worksheet_change event like so. Checks a value in A1 and
if below 10 it colours B1 red

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
If Target.Value < 10 Then
Target.Offset(0, 1).Interior.Color = RGB(255, 0, 0)
Else
Target.Offset(0, 1).Interior.ColorIndex = xlNone
End If
End If
End Sub

To install right-click the sheet tab and select 'view code...'

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
web:
www.nickhodge.co.uk
blog: www.nickhodge.co.uk/blog/

FREE UK OFFICE USER GROUP MEETING, MS READING, 27th APRIL 2007
www.officeusergroup.co.uk

"mantrid" wrote in message
...
hello again
Can anyone tell me if it is possible to trigger some VBA code when a
number
entered in a particular cell on a worksheet is less than the number in
another cell?. I dont know if cells have events linked to them such as
mouse
down etc

Thanks
Ian






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
displaying running total of value entered in same cell? Colin Fisher Excel Worksheet Functions 6 January 21st 09 09:52 PM
Envoke code with button rather than as data is entered. JOUIOUI Excel Programming 0 November 28th 06 08:32 PM
Running a variable macro when any value is entered into a variable cell [email protected] Excel Programming 3 December 14th 05 05:15 PM
Running a macro if any data is entered in a range of cells Jonathan Excel Worksheet Functions 3 November 16th 05 08:38 PM
Check cell for data before running code Pat Excel Programming 1 January 12th 05 08:58 PM


All times are GMT +1. The time now is 02:21 AM.

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"