View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Problem with Worksheets v Ranges 'Again'

Range2 is a variable, a range object variable, not a property of
Worksheets("ColumnSplits"), so don't qualify it as such, i.e.

With Worksheets("ColumnSplits")
.Range2.Select
End With

should just be

Range2.Select

BTW, you can define it a little simpler

Set Range1 = Range("A" & StartRange1 & ":" & "A" & EndRange1)

becomes

Set Range1 = Range("A" & StartRange1 & ":A" & EndRange1)

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Ade" wrote in message
...
I seem to have a lot of difficulty using / selecting ranges that i have
defined on different Worksheets. I have read that you need to explictly
define the range which I often try to do - with usually poor results as I
always get the syntax wrong.
My current problem occurs in the following code module :-

Dim Range1 As Range
Dim Range2 As Range
Dim StartRange1 As Integer
Dim EndRange1 As Integer
Dim StartRange2 As Integer
Dim EndRange2 As Integer
Const RangeSize As Integer = 55


Sub Init()
StartRange1 = 3
EndRange1 = 57
StartRange2 = 2
EndRange2 = 56
Set Range1 = Range("A" & StartRange1 & ":" & "A" & EndRange1)
Set Range2 = Worksheets("ColumnSplits").Range("A" & StartRange2 & ":" &
"A" & EndRange2)
Range1.Select
With Worksheets("ColumnSplits")
.Range2.Select
End With

End Sub

Error : 'Object does not support this property or method' at the line near
the bottom '.Range2.Select'.

Anyone who can suugest the correct code to Select Range2? Also is there
any
usefull methods for figuring out which code syntax you have to use when
working with ranges on different Worksheets as it never seems obvious to
me,
for example in my code I can not see why the line '.Range2.Select' will
not
work, it seems like the obvious solution to me.

Cheers