Only recognizing when a cell value changes

kotting

New Member
Joined
Mar 18, 2002
Messages
17
I currently have a macro that starts when a change is made in a specific range on the worksheet.

My problem is that the macro runs for every cell in the range.

Sample - BT7 value changes to 4. Then the macro is triggered. It compares each cell value in the range to a set of criteria. I only want that specific cell to be recognized because only that cells data changed.

Currently I use "If then" statements to direct from the Worksheet code to six separate 'sub' statements in macros.

The data in the defined range will continue to change as the worksheet is used so i can't compare to a predetermined value.

Is there any hope?

Thanks Again
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi

Question on this:
The data in the defined range will continue to change as the worksheet is used so i can't compare to a predetermined value.
Do you need to reference a cell to gather the conditional value?
Paste a sample of your code and the cell references which the code needs in order to make a decision.
Give as much detail as your willing to give and I guarantee someone in here can solve your problem...

Try this for now.
Place a condition on running your macro...
in change event


If target.row = 7 and _
target.column = 72 then'the 72 is Colum BT
RunMyMacro
end if

Have a nice day
Tom
This message was edited by TsTom on 2002-03-26 05:34
 
Upvote 0
Hi

If the Worksheet_Change event, try

If Not Itersect(Target, Range("A1:D20")) Is Nothing Then
'Do It!
End If
 
Upvote 0
OK, TsTom here is my code. . . .beware that I am a novice and working at learning as I go. This is probably far from optimal.

NOTE - I use =counta(E7:H7, I11:L11, M15:P15) in cell BT7 and other ranges in BT8 and so on. . . .


*****************************************************************************************
Private Sub Worksheet_Change(ByVal Target As Range)





If Range("BT7") > 0 And Range("BT7") < 6 Then
Call FillColor
Else: Call Kladblok
End If


If Range("BT8") > 0 And Range("BT8") < 6 Then
Call Fillcolor1
Else: Call Kladblok1
End If


If Range("BT9") > 0 And Range("BT9") < 6 Then
Call Fillcolor2
Else: Call Kladblok2
End If


If Range("CA7") > 0 And Range("CA7") < 6 Then
Call Fillcolor3
Else: Call Kladblok3
End If


If Range("CA8") > 0 And Range("CA8") < 6 Then
Call Fillcolor4
Else: Call Kladblok4
End If


If Range("CA9") > 0 And Range("CA9") < 6 Then
Call Fillcolor5
Else: Call Kladblok5
End If




End Sub

*******************************************************************************************


Option Explicit

Sub Fillcolor1()
'
' Fillcolor1 Macro
' Macro recorded 26/03/2002 by K. A. Otting
'

'
With Range("E8:F8,E8:H8,I12:L12,M16:P16").Interior
.ColorIndex = 35
.Pattern = xlSolid
End With

End Sub
Sub Kladblok1()
'
' Kladblok1 Macro
' Macro recorded 26/03/2002 by K. A. Otting
'

'

With Range("E8:H8").Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
With Range("I12:J12,I12:L12,M16:P16").Interior
.ColorIndex = xlNone
End With
End Sub
Sub Fillcolor2()
'
' Fillcolor2 Macro
' Macro recorded 26/03/2002 by K. A. Otting
'

'
With Range("E9:F9,E9:H9,I13:L13,M17:P17").Interior
.ColorIndex = 36
.Pattern = xlSolid
End With

End Sub
Sub Kladblok2()
'
' Kladblok2 Macro
' Macro recorded 26/03/2002 by K. A. Otting
'

'
With Range("I13:L13,M17:P17").Interior
.ColorIndex = xlNone
End With
Range("E9:H9").Interior.ColorIndex = 15

End Sub
*********************************************

That is the idea. . . . I tried to add a copy of my spreadsheet but couldn't figure out how.

Thanks for the help.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,694
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top