Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to run this function but I'm getting an error witht the
Intersect function for my second worksheet. Any idea why?! Function SelectRangeToChange(X As Range, ToFind1 As String, ToFind2 As String, TabNum As Variant) As Range Dim Selection As Range, Cell As Range, ToChange1 As Range, ToChange2 As Range, ToChange3 As Range For i = 1 To TabNum Step 1 Worksheets(i).Select Set Selection = Intersect(X, ActiveSheet.UsedRange) ***************PROBLEM****** For Each Cell In Selection If (((Cell.Value) = ToFind1) Or (InStr(1, Cell.Value, ToFind1, vbTextCompare))) Then If ToChange1 Is Nothing Then Set ToChange1 = Cell Else: Set ToChange1 = Union(ToChange1, Cell) End If ElseIf (((Cell.Value) = ToFind2) Or (InStr(1, Cell.Value, ToFind2, vbTextCompare))) Then If ToChange2 Is Nothing Then Set ToChange2 = Cell Else: Set ToChange2 = Union(ToChange2, Cell) End If Else If ToChange3 Is Nothing Then Set ToChange3 = Cell Else: Set ToChange3 = Union(ToChange3, Cell) End If End If Next Cell Next i End Function Thanks, |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Intersect | Excel Programming | |||
intersect function problem | Excel Programming | |||
how to get the intersect cell data out using vba or function | Excel Worksheet Functions | |||
Opposite of Intersect function - an example | Excel Programming | |||
Syntax problem with" intersect" | Excel Programming |