LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Intersect Function Problem

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
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
Intersect [email protected] Excel Programming 2 July 19th 06 10:41 PM
intersect function problem pumpbhoy Excel Programming 2 February 16th 05 08:19 AM
how to get the intersect cell data out using vba or function mango Excel Worksheet Functions 1 December 30th 04 09:46 AM
Opposite of Intersect function - an example DataFreakFromUtah Excel Programming 1 September 17th 04 11:30 PM
Syntax problem with" intersect" Imbecill[_2_] Excel Programming 2 May 29th 04 06:38 PM


All times are GMT +1. The time now is 06:03 PM.

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"