ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range (variable) (https://www.excelbanter.com/excel-programming/375888-range-variable.html)

LyleF

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

bobbo

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



bobbo

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



LyleF

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




Bob Phillips

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






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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com