Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 921
Default Expanding ranges in macros

I have a block of data A1..G50. I'm using a macro to add additional rows one
at a time. How do I set it up to find row 51 for the first add? Using macro
recorder, I started at cell A1 and used END DOWN and DOWN once more to get to
A51. This works the first time, but when I run the macro again, it stops at
A51 (should be A52 the second time). Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Expanding ranges in macros

lastrow=cells(rows.count,1).end(xlup).row+1

As always, post your code for comments. There are probably other things that
could stand a look.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jeff" wrote in message
...
I have a block of data A1..G50. I'm using a macro to add additional rows
one
at a time. How do I set it up to find row 51 for the first add? Using
macro
recorder, I started at cell A1 and used END DOWN and DOWN once more to get
to
A51. This works the first time, but when I run the macro again, it stops
at
A51 (should be A52 the second time). Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 921
Default Expanding ranges in macros

Don - Thanks, but I don't understand how to read your response. Is this
something I can do in the process of recording the macro? How do I use this?

"Don Guillett" wrote:

lastrow=cells(rows.count,1).end(xlup).row+1

As always, post your code for comments. There are probably other things that
could stand a look.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jeff" wrote in message
...
I have a block of data A1..G50. I'm using a macro to add additional rows
one
at a time. How do I set it up to find row 51 for the first add? Using
macro
recorder, I started at cell A1 and used END DOWN and DOWN once more to get
to
A51. This works the first time, but when I run the macro again, it stops
at
A51 (should be A52 the second time). Thanks.



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Expanding ranges in macros

There is no effective way to record what you are doing in a macro. You need
to write it from scratch. To that end what Don's code is doing is it is
determining the last row number which you can use in your code. Perhaps this
will be more to your liking...

cells(rows.count, "A").end(xlUp).offset(1,0).Select

Place this single line of code where you want to select the first blank cell
in column A. What it does is it looks up from the bottom of column A of your
spreadsheet finding the first populated cell. It offsets down 1 row and
selects that cell...
--
HTH...

Jim Thomlinson


"Jeff" wrote:

Don - Thanks, but I don't understand how to read your response. Is this
something I can do in the process of recording the macro? How do I use this?

"Don Guillett" wrote:

lastrow=cells(rows.count,1).end(xlup).row+1

As always, post your code for comments. There are probably other things that
could stand a look.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jeff" wrote in message
...
I have a block of data A1..G50. I'm using a macro to add additional rows
one
at a time. How do I set it up to find row 51 for the first add? Using
macro
recorder, I started at cell A1 and used END DOWN and DOWN once more to get
to
A51. This works the first time, but when I run the macro again, it stops
at
A51 (should be A52 the second time). Thanks.



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
auto-expanding chart- dynamic ranges winewoman Excel Worksheet Functions 1 February 21st 08 07:38 PM
using named ranges in macros Dave F Excel Discussion (Misc queries) 0 November 29th 06 05:13 PM
using named ranges in macros Dave F Excel Discussion (Misc queries) 0 November 29th 06 04:08 PM
Using Query and expanding named ranges [email protected] Excel Discussion (Misc queries) 1 July 21st 06 08:35 PM
Named ranges in macros? fverlaine Excel Discussion (Misc queries) 3 December 14th 05 05:34 PM


All times are GMT +1. The time now is 12:26 PM.

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"