Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default New to excel macros need help with selecting ranges

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default New to excel macros need help with selecting ranges

Hi,

Try this

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

Mike

" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default New to excel macros need help with selecting ranges

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

wrote in message
...
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default New to excel macros need help with selecting ranges

On May 28, 2:41*pm, "Don Guillett" wrote:
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
wrote in message

...



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- Hide quoted text -


- Show quoted text -



Thank you all for your help. Your information pointed me in the
direction to accomplish my selection.
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 ICONS for Macros in Excel 2007 pcor New Users to Excel 1 April 24th 08 09:37 AM
Selecting ranges in macros carl Excel Programming 1 July 17th 07 05:04 PM
how do I use formulas with changing ranges in excel with macros cinvic Excel Discussion (Misc queries) 0 January 21st 06 04:17 PM
Can Excel Macros and Ranges be streamed ? GIMME Excel Programming 0 May 12th 04 04:08 AM
selecting ranges MDC Excel Programming 1 July 24th 03 03:34 PM


All times are GMT +1. The time now is 04:05 PM.

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"