Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 390
Default Selecting a variable range

I am trying to select a range starting with A6 and ending with the last entry
in column A and including 13 columns to the right. I have the code below,
but it doesn't work. The last line the containg the range "A6:LwrRight"
doesn't work. I think it's because I'm using a range where a cell reference
is needed. Any Help. Thanks
Bill

Private Sub

Dim LwrRight As Range
Range("A6").Select
'Range(Selection, Selection.End(xlDown)).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 13).Activate
Set LwrRight = ActiveCell
Range("A6:LwrRight").Select

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Selecting a variable range

Try this

Sub test()

Dim x As Long
Dim rngRange As Range

With ActiveSheet
x = .Range("A65536").End(xlUp).Row
End With
Set rngRange = Range("A6:M" & x)
rngRange.Select

End Sub

"Bill" wrote in message
...
I am trying to select a range starting with A6 and ending with the last
entry
in column A and including 13 columns to the right. I have the code below,
but it doesn't work. The last line the containg the range "A6:LwrRight"
doesn't work. I think it's because I'm using a range where a cell
reference
is needed. Any Help. Thanks
Bill

Private Sub

Dim LwrRight As Range
Range("A6").Select
'Range(Selection, Selection.End(xlDown)).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 13).Activate
Set LwrRight = ActiveCell
Range("A6:LwrRight").Select

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Selecting a variable range

dim wks as worksheet
dim myRng as Range
dim LastRow as long

set wks = worksheets("Sheet1")
with wks
lastrow = .cells(.rows.count,"A").end(xlup).row
set myrng = .range("a6:M" & lastrow)
'more stuff
end with

I stopped with column M. Was that 13 to the right?

Bill wrote:

I am trying to select a range starting with A6 and ending with the last entry
in column A and including 13 columns to the right. I have the code below,
but it doesn't work. The last line the containg the range "A6:LwrRight"
doesn't work. I think it's because I'm using a range where a cell reference
is needed. Any Help. Thanks
Bill

Private Sub

Dim LwrRight As Range
Range("A6").Select
'Range(Selection, Selection.End(xlDown)).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 13).Activate
Set LwrRight = ActiveCell
Range("A6:LwrRight").Select

End Sub


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Selecting a variable range

Range("A6").Resize(Cells(Rows.Count,"A").End(xlUp) .Row-5,13).Select

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Bill" wrote in message
...
I am trying to select a range starting with A6 and ending with the last

entry
in column A and including 13 columns to the right. I have the code below,
but it doesn't work. The last line the containg the range "A6:LwrRight"
doesn't work. I think it's because I'm using a range where a cell

reference
is needed. Any Help. Thanks
Bill

Private Sub

Dim LwrRight As Range
Range("A6").Select
'Range(Selection, Selection.End(xlDown)).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 13).Activate
Set LwrRight = ActiveCell
Range("A6:LwrRight").Select

End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Selecting a variable range

Range("A6",cells(rows.count,1).End(xlup)).Resize(, 13).Select

--
Regards,
Tom Ogilvy


"Bill" wrote:

I am trying to select a range starting with A6 and ending with the last entry
in column A and including 13 columns to the right. I have the code below,
but it doesn't work. The last line the containg the range "A6:LwrRight"
doesn't work. I think it's because I'm using a range where a cell reference
is needed. Any Help. Thanks
Bill

Private Sub

Dim LwrRight As Range
Range("A6").Select
'Range(Selection, Selection.End(xlDown)).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 13).Activate
Set LwrRight = ActiveCell
Range("A6:LwrRight").Select

End Sub

Reply
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
selecting Variable range katmando[_10_] Excel Programming 4 May 18th 06 09:51 AM
selecting a variable row range Dan Excel Programming 2 March 5th 05 12:03 PM
Selecting a variable range Dan Excel Programming 2 November 2nd 04 06:02 AM
Selecting a variable range Colin Foster[_3_] Excel Programming 3 October 26th 04 11:02 PM
Selecting a Range Using a Variable Bob J. Excel Programming 4 September 14th 03 09:24 PM


All times are GMT +1. The time now is 08:06 AM.

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"