ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to verify if a range (or a cell) is contained in another range (https://www.excelbanter.com/excel-programming/420888-how-verify-if-range-cell-contained-another-range.html)

Nicola M

How to verify if a range (or a cell) is contained in another range
 
Hi all.
As above written, how can i get this? The issue is the follow: with VBA I
extended conditional formatting with a lot of features, exceeding the normal
3 condition. Now I need this "personal conditional formatting" works only for
the changed cell in a specific range and not in alla worksheet.

Thank you in advance for tips, advice and suggestions.
Nicola

JMay

How to verify if a range (or a cell) is contained in another range
 
From Immediate Window

? Not Application.Intersect(Range("Range1"),Range("Range 2")) is Nothing
True << produced answer..

"Nicola M" wrote:

Hi all.
As above written, how can i get this? The issue is the follow: with VBA I
extended conditional formatting with a lot of features, exceeding the normal
3 condition. Now I need this "personal conditional formatting" works only for
the changed cell in a specific range and not in alla worksheet.

Thank you in advance for tips, advice and suggestions.
Nicola


Mike H

How to verify if a range (or a cell) is contained in another range
 
Nicola,

One way is with worksheet change where you can capture the address of the
cell that has changed and act accordingly. The code below only executes if
the changed cell is in the range A1 - A100.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
'If Not Intersect(Target, Range("A1:A100")) Is Nothing Then

Application.EnableEvents = False

'do things
Application.EnableEvents = True
End If
End Sub


Mike


"Nicola M" wrote:

Hi all.
As above written, how can i get this? The issue is the follow: with VBA I
extended conditional formatting with a lot of features, exceeding the normal
3 condition. Now I need this "personal conditional formatting" works only for
the changed cell in a specific range and not in alla worksheet.

Thank you in advance for tips, advice and suggestions.
Nicola


Gary''s Student

How to verify if a range (or a cell) is contained in another range
 
Sub ProperSubSet()
Dim littleRange As Range
Dim bigRange As Range
Dim r As Range
Set littleRange = Range("A2:D9")
Set bigRange = Range("A1:Z100")
For Each r In littleRange
If Intersect(r, bigRange) Is Nothing Then
MsgBox ("Little not contained with Big")
Exit Sub
End If
Next
MsgBox ("Little contained with Big")
End Sub

--
Gary''s Student - gsnu200817

Nicola M

How to verify if a range (or a cell) is contained in another r
 
Thank you so much, guys. It's just that I was looking for
[CUT]


All times are GMT +1. The time now is 01:27 PM.

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