New to excel macros need help with selecting ranges

I

irishiii75

I have need a macro that will select a range in a column and copy
data.
In one spreadsheet the column range maybe N2 - N15
the next time the column range maybe N2 - N250

How can I code it to select N2 - last cell in column so I don't have
to change macro each time for each spreadsheet.

Thank you

Terrie
 
M

Mike H

Hi,

Try this

lastrow = Cells(Rows.Count, "N").End(xlUp).Row
Range("N2:N" & lastrow).Select

Mike
 
D

Don Guillett

How about a nice one liner broken up to account for possible word wrap. NO
selections

Sub copyrng()
Cells(2, 4).Resize(Cells(Rows.Count, 4). _
End(xlUp).Row - 1).Copy range("z5")
End Sub
 
I

irishiii75

How about a nice one liner broken up to account for possible word wrap. NO
selections

Sub copyrng()
Cells(2, 4).Resize(Cells(Rows.Count, 4). _
  End(xlUp).Row - 1).Copy range("z5")
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software








- Show quoted text -


Thank you all for your help. Your information pointed me in the
direction to accomplish my selection.
 
D

Don Guillett

Glad to help. However, it is not necessary to SELECT. Post your code for
comments.


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
[email protected]
How about a nice one liner broken up to account for possible word wrap. NO
selections

Sub copyrng()
Cells(2, 4).Resize(Cells(Rows.Count, 4). _
End(xlUp).Row - 1).Copy range("z5")
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software








- Show quoted text -


Thank you all for your help. Your information pointed me in the
direction to accomplish my selection.
 
Top