Target.Address Question

  • Thread starter Thread starter Leiprecht
  • Start date Start date
L

Leiprecht

How do you use If Target.Address = _____ Then for more than one cells.

The cells I want are
F67 Or F73 Or F79 Or F85 Or F91 Or F97 Or F103 Or F109 Or F115 Or F121 Or
F127 Or F133 Or F139 Or F145

Thanks for your help in advance.
 
Sub dural()
Set r =
Range("F67,F73,F79,F85,F91,F97,F103,F109,F115,F121,F127,F133,F139,F145")
MsgBox (r.Address)
Set Target = ActiveCell
If Intersect(Target, r) Is Nothing Then
' do something
Else
'do something else
End If
End Sub
 
Hi

Look at this:

Set TestRange = Range _
("F67 , F73, F79, F85, F91, F97, F103, F109, F115, F121, F127, F133,
F139, F145")
Set isect = Intersect(Target, TestRange)
If Not isect Is Nothing Then
MsgBox ("Target intersect with TestRange")
End If

Hopes this helps
 
Given the regularity of your ranges (they all differ by 6), you can use this
mathematical relationship to test if the Target row is within your range...

If Abs(Target.Row - 106) <= 39 And ((Target.Row - 67) Mod 6 = 0) Then
 
Back
Top