ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Target.Address Question (https://www.excelbanter.com/excel-programming/426817-target-address-question.html)

Leiprecht

Target.Address Question
 
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.

Gary''s Student

Target.Address Question
 
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

--
Gary''s Student - gsnu200846


"Leiprecht" wrote:

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.


Per Jessen

Target.Address Question
 
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

---
Per

"Leiprecht" skrev i meddelelsen
...
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.



Rick Rothstein

Target.Address Question
 
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

--
Rick (MVP - Excel)


"Leiprecht" wrote in message
...
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.




All times are GMT +1. The time now is 02:24 PM.

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