View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
LabElf LabElf is offline
external usenet poster
 
Posts: 26
Default Bug in Excel 2003

Thank you, keepITcool, I will try your suggestions; however, I would like to
clarify some facts:
The code I posted works correctly in both Excel 2000 and Excel 2003. The
syntax is not erroneous.
The code is cumbersome because the user may have selected a single cell, a
range of contiguous cells, or a disjoint selection containing individual
cells or several contiguous selections (or both). The structure of range
object for the selection is different in each of these cases. (But see my
final paragraph below.)
If the range contains a contiguous group of rows of one column each, the
Value2 property does not contain a one-dimensional array, but rather a
two-dimensional array. The second subscript range is 1 to 1. (I checked
this again in Excel 2003 to make sure I'm reporting the behavior accurately.)
The debugger in Excel 2003 shows a Value2 property, but no Value property,
although obviously it is there in some form because the remaining references
to Value work.
I still think the Excel 2003 interpreter is in error for objecting to syntax
that is not incorrect.

That said, I think I can see where iterating through the Areas collection
could make a simpler loop. I wasn't using the Areas collection when I
started writing this macro because I didn't know how to use it then. I'll
let you know how it works out.

"keepITcool" wrote:


the bug is not a bug.. imo your syntax is erroneous..


'Make next name with this permutation
Call addsingle(xlPnumRange.Value2(lPnumIndex, 1), _
strFormatSpec, strTcId & strTestType)



already part of some 'cumbersome' code to loop a multiarea range
this will very likely go bust..

if xlPnumRange is a 1 row, multicolumn range (may be 1 area of your
entire selection) the Value or Value2 of that range will be returned as
a 1 dimensional array.

dim v(1) = debug.print v(1,1) will produce an error.

Thus you might use:
Call addsingle(xlPnumRange.Cells(lPnumIndex, 1).Value, _
strFormatSpec, strTcId & strTestType)

Note that when enumerating ROWS inside a range you cannot abbreviate
getting the first cell of the row range like xlRow(1,1).. you must use
xlRow.Cells(1,1). To avoid confusion avoid the abbreviated syntax
altogether.


But even then I'd code your entire for each differently.

After your loop:

'Get selected cells
Set xlPnumRange = Selection

Dim xlArea As Range, xlRow As Range
For Each xlArea In xlPnumRange.Areas
For Each xlRow In xlArea.Rows
'Get good format spec
strFormatSpec = adjustformat(xlRow)
'Make next name with this permutation
Call addsingle(xlRow.Cells(1,1).Value, _
strFormatSpec, _
strTcId & strTestType)
Next
Next

Can't test but that should do the same as your code.


HTH

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


LabElf wrote :

OK, for anyone who is interested, here is the code for the AddTest
macro. It calls some other macros, and makes some assumptions about
the worksheet it is called from, but I think it should be fairly
clear.


SNIP



"keepITcool" wrote:

post your code, so we may (dis)agree or advise

--
keepITcool
www.XLsupport.com | keepITcool chello nl | amsterdam