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: 7
Default for each in range gives variant array

Hello,

I have a range, which i define as:

Set rngSearch = ws.UsedRange.Rows(intRow)


I then call the following function:

strTemp = FindMatchAddr(rngSearch, "Text")


whe

Function FindMatchAddr(rngSearch As Range, strFind As String) As
String
'returns the address of the cell in rngSearch that contains strFind

Dim cTemp As Range

For Each cTemp In rngSearch
If Trim(CStr(cTemp.Value)) = strFind Then
FindMatchAddr = cTemp.AddressLocal
Exit Function
End If
Next cTemp

FindMatchAdd = "not found"

End Function


Normally, I would expect this to go through and check each cell in
rngSearch. Instead, it is giving me a "type incompatibilty" error,
and the spy window tells me that cTemp.value is a "Variant/Variant(1
to 1, 1 to 66) ".

By being a bit more precise (using cTemp.Cells(1,1).Value), I can get
around this, but I've used For Each cTemp in rngRange structures
before and it has always worked.

I think that this problem stems from my having misunderstood something
simple, i'd very much appreciate it if someone could explain to me why
it is happening.

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
Write from variant array into range Bharath Rajamani Excel Programming 1 May 9th 07 11:24 AM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 6 November 9th 05 05:54 AM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 1 November 8th 05 04:21 AM
Best way to paste a variant array into a range? AnneB Excel Programming 2 April 28th 04 09:57 PM
variant array containing cel adresses convert to actual ranges-array Peter[_21_] Excel Programming 5 December 10th 03 09:50 PM


All times are GMT +1. The time now is 06:53 AM.

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"