LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Combine Intersect Range in If statements

I don't understand what you're doing, but maybe this will give you an outline:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count 1 Then Exit Sub

On Error GoTo ErrHandler

If Not Intersect(Me.Range("L2:m20"), Target) Is Nothing Then
'you're in L2:M2, so do the stuff for L2:M2 here
'some code
'some more code
Application.EnableEvents = False
'change some cells on the worksheet

ElseIf Not Intersect(Me.Range("A2:B2"), Target) Is Nothing Then
'you're in A2:B2
'do what you need
Application.EnableEvents = False
'change some different cells on the worksheet

End If

ErrHandler:
Application.EnableEvents = True
End Sub


Ben Dummar wrote:

I am trying to combine the two intersect ranges below into one macro that is
in a worksheet tab. The outside if range works but the inside one doesn't.
What do I need to do to fix it?

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Dim R As Long
R = Target.Row

On Error GoTo ErrHandler
Application.EnableEvents = True


If Not Intersect(Range("L2:m20"), Target) Is Nothing Then
If Not Intersect(Range("A2:B2"), Target) Is Nothing Then
End If

If Target.Column < 9 Then Exit Sub
If Target.Row = 1 Then Exit Sub

Target.Offset(0, -2).Value = Date '<<== CHECK RANGE
End If

If Target.Column < 2 Then Exit Sub
If Target.Row = 1 Then Exit Sub

Target.Offset(0, 2).Value = Date




ErrHandler:
Application.EnableEvents = True
End Sub

Thanks,

Ben


--

Dave Peterson
 
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
IF statements referencing an absolute value or a range of values skaminski Excel Worksheet Functions 6 April 4th 23 12:45 PM
How can I intersect 2 trendlines on the same spreadsheet? harbal2007 Excel Discussion (Misc queries) 1 February 8th 07 08:29 PM
Intersect operations heyes Excel Worksheet Functions 4 February 14th 06 05:13 PM
Combine multiple cells into one cell range. grady88 Excel Worksheet Functions 1 October 12th 05 08:03 PM
how to combine cells by selecting range? SPIRIT New Users to Excel 3 August 20th 05 10:40 AM


All times are GMT +1. The time now is 08:53 AM.

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

About Us

"It's about Microsoft Excel"