Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Intersecting addresses from two sheets
I am a newbie and I don't know the answer, but if you don't mind I
would like to add to the question. I have XP version. I have tried this line If Intersect(Sht.Range("$A$1"), Sht.UsedRange) Then which fails at runtime - Type Mismatch. But in the debug window ?Intersect(Sht.Range("$A$1"), Sht.UsedRange) shows the contents of cell A1! (Not only that... Intersect(Sht.Cells(1, 1), Sht.UsedRange) doesn't work in either! I thought both my args are ranges??) So (pushing my luck) 2 questions: 1. I thought Intersect returned a range. Is the debug window just showing the .Value as a convenience? 2. Why does the statement work in the debug window but fail in code? (and why does the .Cells fail) NOTE: Sht is not the active sheet. I figured that might be important! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Intersecting addresses from two sheets
You're treating that Intesect() expression as a boolean (= true or = false).
Try if intersect(...) is nothing then 'nothing in common else 'something in common end if 1. Intersect will return a range or Nothing (depending) 2. And the watch window will show you the default property's value (.value for range objects) as a help. Barney Fife wrote: I am a newbie and I don't know the answer, but if you don't mind I would like to add to the question. I have XP version. I have tried this line If Intersect(Sht.Range("$A$1"), Sht.UsedRange) Then which fails at runtime - Type Mismatch. But in the debug window ?Intersect(Sht.Range("$A$1"), Sht.UsedRange) shows the contents of cell A1! (Not only that... Intersect(Sht.Cells(1, 1), Sht.UsedRange) doesn't work in either! I thought both my args are ranges??) So (pushing my luck) 2 questions: 1. I thought Intersect returned a range. Is the debug window just showing the .Value as a convenience? 2. Why does the statement work in the debug window but fail in code? (and why does the .Cells fail) NOTE: Sht is not the active sheet. I figured that might be important! -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using Intersecting Names for lookup | Excel Discussion (Misc queries) | |||
vlookup, hlookup and return value of intersecting cell | Excel Discussion (Misc queries) | |||
Testing if a point is falling within the bounds of intersecting cu | Excel Worksheet Functions | |||
Testing if a point is falling within the bounds of intersecting cu | Excel Discussion (Misc queries) | |||
RETURN intersecting value with known horizotal & vertical?? | Excel Worksheet Functions |