when looking at a range can certain rows be missed out

R

RobG2007

Below is my code for changing a value in a cell depending on what values are
in a range of rows.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo ErrHandler
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C2:C20")) Is Nothing Then
Range("E63") = (Range("C63") - Target.Value)
End If
ErrHandler:
Application.EnableEvents = True
End Sub


But is it possible to miss out certain rows of the range for example

my range is A1:A100 but i dont want to include A23 and A25 is this possible
 
J

Jim Thomlinson

My preference for doing something like this would be to use a named range.
Create the range excluding the two cells. Part of the reason I like this
method is that if down the road the range changes then you do not need to
modify any code.

You can do it directly in the code but it is more cumbersome and if anything
changes then you will need to change the code.
 
J

Jim Cone

Your posted code refers to cells in Columns C and Columns E.
How do cells from Column A become involved?
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"RobG2007"
<[email protected]>
wrote in message
Below is my code for changing a value in a cell depending on what values are
in a range of rows.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo ErrHandler
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("C2:C20")) Is Nothing Then
Range("E63") = (Range("C63") - Target.Value)
End If
ErrHandler:
Application.EnableEvents = True
End Sub

But is it possible to miss out certain rows of the range for example
my range is A1:A100 but i dont want to include A23 and A25 is this possible
 

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