Selecting a variable range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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?
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top