View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Set Range.....am I to blind?


the why bother to
use an object at all?


Because the entire object model -- the application's very definition -- is
comprised almost completely of objects, so using the built-in object types
allows your code to mesh seamlessly with the native Excel application. To
understand objects, you need to understand classes; an object is a class
that is loaded into memory. See http://www.cpearson.com/Excel/Classes.aspx
for an introduction to user created classes and objects.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Ross Culver" wrote in message
...
Yeah. I never use objects, only cell/range references and variables. In
fact, if you would and when you have time, briefly explain the why bother
to use an object at all? I need to learn something new today.

Ross

"carlo" wrote in message
...
Thank you all for replying.

@Ross:
the Set is mandatory because copy_rng is an object!

Carlo


On Nov 29, 11:12 am, carlo wrote:
Thanks Basilisk96

I just tried a little bit more and i found out following:
'-------------------------------------------------------
dim copy_rng as range
set copy_rng = worksheets("sheet2").range("A1:T1") '<--works
set copy_rng = worksheets("sheet2").range(cells(1,1),cells(1,20)) '<--
works not
set copy_rng =
worksheets("sheet2").range(worksheets("sheet2").ce lls(1,1),worksheets("shee-t2").cells(1,20))
'<-- works
'-------------------------------------------------------

i have to give Excel the parent to all the cells!
I thought the cells() in the range object are just for the addresses
sake, but I was wrong, they have to be on the same sheet, so I need to
specify the parentsheet for every cell.

thank you very much, sorry for the confusion.

cheers and thanks

Carlo

On Nov 29, 11:06 am, Basilisk96 wrote:



On Nov 28, 8:52 pm, carlo wrote:

Do I become senile? This thing is driving me crazy!

I recall, I had this problem once...
You're fine, you just need some time AFK for a fresh perspective ;-)

Think about this, and you will see the light, I promise:
Who is the parent of your Cells() calls? That's right, qualify them
explicitly, and it will work in all cases.

;)
Cheers,
-Basilisk96- Hide quoted text -

- Show quoted text -