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: 279
Default for each in a range

I run Excel 2003 and VBA 6.5.

I have a very limited understanding of VBA's Range object.

I hit this on a sheet which has relevant formulae in column C.
I want to treat the first formula as special.
I have the following code extract:
....
Dim PeakOyster As Boolean
Dim Trips As Range
....
Set Trips = Columns(3).SpecialCells(xlCellTypeFormulas)
PeakOyster = (Trips.Item(0)(1, -1) < 930 And Left(Cells(2, 2), 1) < "S")
For Each C In Trips
....

Trips.Item(0) is evaluated without error.
This surprises me as Item is not shown as a member of Trips in the VBA
Locals Window, nor is it a documented member of the Range object.

The first formula is in $C$9.
However the Immediates Window shows
?trips.Item(0).address
$C$8
?trips.Address
$C$9:$C$10,$C$15,$C$18,$C$24,$C$26,$C$33,$C$35,$C$ 41,$C$43,$C$49,$C$51,$C$57:$C$58
?trips(1,-1).address
$A$9

i.e. trips.Item(0).address is $C$8, where I expect $C$9.

I can correct my code to
PeakOyster = (Trips(1, -1) < 930 And Left(Cells(2, 2), 1) < "S")

I don't understand the logic of what I see.
I would value an explanation and a reference to documentation.
I'll even buy a book, if necessary. ;)

P.S. Since starting to write this, I have found
?trips.Item(1).address
$C$9
i.e. Item is equivalent to a base 1 array and
for each Q in Columns(3).SpecialCells(xlCellTypeFormulas):? Q.address:next
$C$9
$C$10
$C$15
....

My code now contains:
' Trips.Item is absent from the Locals Window and is 1-based
PeakOyster = Trips.Item(1)(1, -1) < 930 And Not Cells(2, 2) Like "S*"
--
Walter Briscoe
 
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
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
Range Question / error 1004: method Range of object Worksheet has failed Paul Excel Programming 3 April 7th 05 02:56 PM
Range.Find returns cell outside of range when range set to single cell Frank Jones Excel Programming 12 June 10th 04 04:22 AM
how to? set my range= my UDF argument (range vs. value in range) [advanced?] Keith R[_3_] Excel Programming 2 August 11th 03 05:55 PM


All times are GMT +1. The time now is 05:45 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"