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: 90
Default How do range objects work?

[This followup was posted to and a copy was sent to the cited author.]

G'day there One & All,

I'm back on the group with a question again, but this one's more
for curiosity than for need.

I'm sure that I've found a bug in Excel. It's more likely just a
bug in the way I perceive that Excel should work, but I'd rather blame
Microsoft than admit to a personal deficiency =)

What I have is a sheet with, amongst other things, a range object
consisting of 2 discontiguous rows of 13 cells each. Ie:

Set nGrid = Union(Sheet1.Range(Cells(ntrow, gsLft), Cells(ntrow,
gsLft + 12)), Sheet1.Range(Cells(nbrow, gsLft), Cells(nbrow, gsLft +
12)))

ntrow = top row
nbrow = bottom row
gsleft = left column

The variables give me the following address for nGrid -
$D$22:$P$22,$D$25:$P$25

That bit works fine. If I tell nGrid to have a green background
and glow in the dark then both sets of cells do exactly that.

I want to have the cells contain the numbers 1 to 26. Obviously,
13 in each row. I thought that I could use the ".item" property but I
couldn't figure out a way to do so. I then decided on to use the old
"For x = 1 to 26" technique thusly:

Dim x As Integer
For x = 1 To 26
nGrid.Cells(x).Value = x
Next

That worked fine for the first 13 cells, but then it all went
awry. The second row of 'x' values went into the correct columns but in
the row immediately underneath the first:

1 2 3 4 5 6 7 8 9 10 11 12 13
--------------------------------------
14 15 16 17 18 19 20 21 22 23 24 25 26

When it should have been:

1 2 3 4 5 6 7 8 9 10 11 12 13
--------------------------------------

--------------------------------------

--------------------------------------
14 15 16 17 18 19 20 21 22 23 24 25 26


A couple of debug.prints before & after for loop indicate that
Excel is well aware of the address, giving the same as detailed above.
However it doesn't write the values into row 25, but into 23!!! It's
obvious that the correct address is being read as indicated by the green
glowing in the dark. What gives? Why doesn't it write the values into
the correct row? The address is obviously being read ok as the columns
are all correct.

It's easy to get around, by just writing to the nominated row, but
I don't understand the mechanism behind why this doesn't work. Any ideas
anyone?

See ya
Ken McLennan
Qld, Australia
 
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
Auto Filter does not work with embedded objects [email protected] Excel Worksheet Functions 2 October 4th 07 02:15 AM
Can't Get Objects To Work In A Protected Worksheet OMMBoy Excel Worksheet Functions 2 May 27th 06 06:28 PM
Cut Drawing Objects within a range CLR Excel Programming 1 January 20th 06 05:31 PM
Range objects (?) Bill[_19_] Excel Programming 1 December 23rd 03 02:37 PM
Cannot use range objects jason Excel Programming 7 November 27th 03 03:00 AM


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