Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macros - Relative cells in Excel

How can you program a macro to select data to the bottom of a list rather
than to a specific cell number? (i.e. for data of varying length)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Macros - Relative cells in Excel

The trick is to selectthe cell at the top of the list, which is known, and
then tell Excel to go all the way down to the last cell before the first
empty one. So, assuming the list starts in D4, the code would be:

Range("D4").Select
Selection.End(xlDown).Select

HTH,
Nikos


"BeardT" wrote in message
...
How can you program a macro to select data to the bottom of a list rather
than to a specific cell number? (i.e. for data of varying length)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macros - Relative cells in Excel

Hi Nikos
That was really useful, thank you. Although I'm now having trouble telling
the macro to move to the cell below the last row of data. So I've got 3 pages
of data that I want to copy and paste into one long list in a separate
workbook. If you use the visual basic command:

Range("D4").Select
Selection.End(xlDown).Select

to move to the end of the data, the row in question contains data that will
be written over if the next set of data is pasted, how do you command the
macro to move down a cell without referring it to a specific cell (e.g. D158)?
Tom


"Nikos Yannacopoulos" wrote:

The trick is to selectthe cell at the top of the list, which is known, and
then tell Excel to go all the way down to the last cell before the first
empty one. So, assuming the list starts in D4, the code would be:

Range("D4").Select
Selection.End(xlDown).Select

HTH,
Nikos


"BeardT" wrote in message
...
How can you program a macro to select data to the bottom of a list rather
than to a specific cell number? (i.e. for data of varying length)




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Macros - Relative cells in Excel

Try something like

Selection.End(xlDown)(2,1).Select


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"BeardT" wrote in message
...
Hi Nikos
That was really useful, thank you. Although I'm now having
trouble telling
the macro to move to the cell below the last row of data. So
I've got 3 pages
of data that I want to copy and paste into one long list in a
separate
workbook. If you use the visual basic command:

Range("D4").Select
Selection.End(xlDown).Select

to move to the end of the data, the row in question contains
data that will
be written over if the next set of data is pasted, how do you
command the
macro to move down a cell without referring it to a specific
cell (e.g. D158)?
Tom


"Nikos Yannacopoulos" wrote:

The trick is to selectthe cell at the top of the list, which
is known, and
then tell Excel to go all the way down to the last cell before
the first
empty one. So, assuming the list starts in D4, the code would
be:

Range("D4").Select
Selection.End(xlDown).Select

HTH,
Nikos


"BeardT" wrote in message
...
How can you program a macro to select data to the bottom of
a list rather
than to a specific cell number? (i.e. for data of varying
length)






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macros - Relative cells in Excel

Chip, you're a legend - works a treat. Thanks for helping

Tom

"Chip Pearson" wrote:

Try something like

Selection.End(xlDown)(2,1).Select


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"BeardT" wrote in message
...
Hi Nikos
That was really useful, thank you. Although I'm now having
trouble telling
the macro to move to the cell below the last row of data. So
I've got 3 pages
of data that I want to copy and paste into one long list in a
separate
workbook. If you use the visual basic command:

Range("D4").Select
Selection.End(xlDown).Select

to move to the end of the data, the row in question contains
data that will
be written over if the next set of data is pasted, how do you
command the
macro to move down a cell without referring it to a specific
cell (e.g. D158)?
Tom


"Nikos Yannacopoulos" wrote:

The trick is to selectthe cell at the top of the list, which
is known, and
then tell Excel to go all the way down to the last cell before
the first
empty one. So, assuming the list starts in D4, the code would
be:

Range("D4").Select
Selection.End(xlDown).Select

HTH,
Nikos


"BeardT" wrote in message
...
How can you program a macro to select data to the bottom of
a list rather
than to a specific cell number? (i.e. for data of varying
length)






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
Excel 2003 macros set relative cell references JPI Excel Discussion (Misc queries) 7 May 21st 07 05:08 AM
Relative Reference Help Macros PhillipsHQ Excel Worksheet Functions 5 August 18th 06 03:29 PM
How can you change excel macros from absolute to relative? Ralonne Excel Worksheet Functions 5 May 30th 06 07:40 PM
Relative References for macros Grace[_4_] Excel Programming 5 June 10th 04 06:09 PM
Excel Relative Macros llockler Excel Programming 1 February 2nd 04 08:44 PM


All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"