Range (variable)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
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.
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top