Range.Select

Visvang
04-26-2010, 05:14 AM
Hi guys,

I want to select a range.

I know the last row : LastRow = Range("E65536").End(xlUp).Row
and I know the last colom is "n"

Now i want to select range("e3", "n" + lastrow)
This is what I did

LastRow = Range("E65536").End(xlUp).Row
LastCell = "n" + Str(LastRow)
MyRange = Range("e3", LastCell)

can anyone pls tell me whats wrong

zebulon72
04-26-2010, 05:23 AM
That looks familier :)
Set myrange = Range("e3", LastCell)
(have done the same error myself)

Colin Legg
04-26-2010, 05:42 AM
Hi,

Hi guys,

I want to select a range.

I know the last row : LastRow = Range("E65536").End(xlUp).Row
and I know the last colom is "n"

Now i want to select range("e3", "n" + lastrow)
This is what I did

LastRow = Range("E65536").End(xlUp).Row
LastCell = "n" + Str(LastRow)
MyRange = Range("e3", LastCell)

can anyone pls tell me whats wrong

In addition to using the Set keyword also make sure that MyRange is declared as a Range, not as a Variant. If declared as a Range then your current code would throw an error (which would help you to identify the problem). Not necessarily how I'd do it, but I think you are trying to emulate one of these:

Dim LastRow As Long
Dim MyRange As Range
Dim LastCell As Range

LastRow = Range("E65536").End(xlUp).Row
Set LastCell = Range("n" & CStr(LastRow))
Set MyRange = Range("e3", LastCell)

or

Dim LastRow As Long
Dim MyRange As Range
Dim LastCell As String

LastRow = Range("E65536").End(xlUp).Row
LastCell = "n" & CStr(LastRow)
Set MyRange = Range("e3", LastCell)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum