Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Range (variable)

I need to copy a range from one sheet into the exact same row in several
other sheets. I also need to make the row a variable so it can be changed
each month and then run the macro with the new row number.
Enddate is the variable and is being picked up correctly. I am getting
error 1004
as I try to pass Enddate into the range. Below is where I am now.

Range("b&Enddate").Select
--
Thanks
Lyle
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Range (variable)

if enddate is a named range then this should work
Range("b" & Names("Enddate").RefersToRange.Row)
Names("Enddate").RefersToRange.row will return the first row of the
named range Enddate.


LyleF wrote:
I need to copy a range from one sheet into the exact same row in several
other sheets. I also need to make the row a variable so it can be changed
each month and then run the macro with the new row number.
Enddate is the variable and is being picked up correctly. I am getting
error 1004
as I try to pass Enddate into the range. Below is where I am now.

Range("b&Enddate").Select
--
Thanks
Lyle


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Range (variable)

Reading your post more closely I think that Endate is a variable in
your procedure.
You just need to replace one of your quotes. This assumes that enddate
returns an integer value that is the row you wish to use.

Range("b" & Enddate).Select

Also you do not have to select a range to manipulate it. This is
probably something that will make your scripting faster.


bobbo wrote:
if enddate is a named range then this should work
Range("b" & Names("Enddate").RefersToRange.Row)
Names("Enddate").RefersToRange.row will return the first row of the
named range Enddate.


LyleF wrote:
I need to copy a range from one sheet into the exact same row in several
other sheets. I also need to make the row a variable so it can be changed
each month and then run the macro with the new row number.
Enddate is the variable and is being picked up correctly. I am getting
error 1004
as I try to pass Enddate into the range. Below is where I am now.

Range("b&Enddate").Select
--
Thanks
Lyle


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Range (variable)

Perfect, I never do get those quotes right the first time.
--
Thanks
Lyle


"bobbo" wrote:

Reading your post more closely I think that Endate is a variable in
your procedure.
You just need to replace one of your quotes. This assumes that enddate
returns an integer value that is the row you wish to use.

Range("b" & Enddate).Select

Also you do not have to select a range to manipulate it. This is
probably something that will make your scripting faster.


bobbo wrote:
if enddate is a named range then this should work
Range("b" & Names("Enddate").RefersToRange.Row)
Names("Enddate").RefersToRange.row will return the first row of the
named range Enddate.


LyleF wrote:
I need to copy a range from one sheet into the exact same row in several
other sheets. I also need to make the row a variable so it can be changed
each month and then run the macro with the new row number.
Enddate is the variable and is being picked up correctly. I am getting
error 1004
as I try to pass Enddate into the range. Below is where I am now.

Range("b&Enddate").Select
--
Thanks
Lyle



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 380
Default Range (variable)

No need to select

Range("B" & EndDate).copy Worksheets("Sheet2").Range("B" & EndDate)

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"bobbo" wrote in message
oups.com...
Reading your post more closely I think that Endate is a variable in
your procedure.
You just need to replace one of your quotes. This assumes that enddate
returns an integer value that is the row you wish to use.

Range("b" & Enddate).Select

Also you do not have to select a range to manipulate it. This is
probably something that will make your scripting faster.


bobbo wrote:
if enddate is a named range then this should work
Range("b" & Names("Enddate").RefersToRange.Row)
Names("Enddate").RefersToRange.row will return the first row of the
named range Enddate.


LyleF wrote:
I need to copy a range from one sheet into the exact same row in

several
other sheets. I also need to make the row a variable so it can be

changed
each month and then run the macro with the new row number.
Enddate is the variable and is being picked up correctly. I am

getting
error 1004
as I try to pass Enddate into the range. Below is where I am now.

Range("b&Enddate").Select
--
Thanks
Lyle




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
variable range John New Users to Excel 2 July 21st 06 03:42 PM
select range and put range address in variable [email protected] Excel Programming 2 January 25th 06 01:28 AM
Macro to copy a specified range to a variable range SWT Excel Programming 4 October 21st 05 08:24 PM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


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