ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   when looking at a range can certain rows be missed out (https://www.excelbanter.com/excel-discussion-misc-queries/151456-when-looking-range-can-certain-rows-missed-out.html)

RobG2007

when looking at a range can certain rows be missed out
 
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

Jim Thomlinson

when looking at a range can certain rows be missed out
 
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.
--
HTH...

Jim Thomlinson


"RobG2007" wrote:

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


Jim Cone

when looking at a range can certain rows be missed out
 

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"

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

RobG2007

when looking at a range can certain rows be missed out
 
it was an example to make life easyer

"Jim Cone" wrote:


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"

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



All times are GMT +1. The time now is 03:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com