Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default how to select multiple rows using a macro

I am trying to use 2 different variables and either the ROWS or RANGE command
in a macro to select a continuous block of rows. I want to copy this block
from one sheet to another sheet. I have been trying to use the following
syntax with no avail: ROWS(firstrownumber,lastrownumber).Select I also
tried using:
RANGE(firstrownumber:firstrownumber,lastrownumber: lastrownumber).Select I
have to use a variable, because the actual row numbers I will be copying and
pasting will change every time I run the macro. I can make it work if I only
select and copy one row at a time, but in one of my sheets I need to select
and copy 2880 rows of data, and doing that one at a time takes about 5
minutes. Any suggestions would be very much appreciated. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default how to select multiple rows using a macro

Range(firstRowNumber & ":" & lastRowNumber).copy

Rows(firstRowNumber & ":" & lastRowNumber).copy

just do demonstrate from the immediate window:

f = 1
l = 2080
? range(f & ":" & l).Address
$1:$2080
? rows(f & ":" & l).Address
$1:$2080



--
Regards,
Tom Ogilvy


"Chad" wrote:

I am trying to use 2 different variables and either the ROWS or RANGE command
in a macro to select a continuous block of rows. I want to copy this block
from one sheet to another sheet. I have been trying to use the following
syntax with no avail: ROWS(firstrownumber,lastrownumber).Select I also
tried using:
RANGE(firstrownumber:firstrownumber,lastrownumber: lastrownumber).Select I
have to use a variable, because the actual row numbers I will be copying and
pasting will change every time I run the macro. I can make it work if I only
select and copy one row at a time, but in one of my sheets I need to select
and copy 2880 rows of data, and doing that one at a time takes about 5
minutes. Any suggestions would be very much appreciated. Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default how to select multiple rows using a macro

Tom,
You are the MAN! I have been struggling with that for several days and was
getting very fustrated. I knew it was a simple syntax error, but just
couldn't figure it out. Thank you again for the quick response and excellent
help!

Chad
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
Select multiple rows not next to each other LarryJNX Excel Worksheet Functions 3 April 4th 23 02:20 PM
using variables to select multiple rows using a macro Chad Excel Programming 1 October 8th 06 11:22 PM
using variables to select multiple rows using a macro Chad Excel Programming 0 October 6th 06 03:31 PM
Select multiple rows and apply changes all at once JPlankenhorn Excel Programming 6 August 17th 06 03:12 PM
how to select multiple rows using vba almostthere Excel Programming 6 June 4th 04 07:48 PM


All times are GMT +1. The time now is 01:10 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"