Variable ranges

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

Guest

Hi,
As i write my code the range that i'm referring to changes. To identify the
lower and the upper limits of the range i use the following

BeginRange = Worksheets("Content").Cells(5, col).Address
EndRange = Worksheets("Content").Cells(Row, col).Address

Now, as i select this range and try to copy it elsewhere i'm trying to use
the following expression:

Worksheets("Content").Range("" & BeginRange & " :" & EndRange & "").Select

Every time I get to this point i get an error '1004' - "Application defined
or object defined error"

Can anyone please advise as to what is going on and how to get arround it?

Thanks a bunch
Igor
 
Must be something wrong with the values in Row and col. What do they contain
at that point.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)
 
If Content isn't the activesheet, you can get this error.

Worksheets("Content").select
Worksheets("Content").Range("" & BeginRange & " :" & EndRange & "").Select

But you could have used:
Worksheets("Content").Range(BeginRange & ":" & EndRange).Select

But I think most would just use:
Worksheets("Content").Range(BeginRange, EndRange).Select
 
Bob,

the value of each reflects the cell.address $z$1 for BeginRange and $z$50
for EndRange. So, the variables are fine and are declared as variant.

Thanks for your help
 
That value works fine for me. You would get an error if Content is not the
activesheet as Dave suggested, but that is a different error than the one
that you reported. Have you debugged it to see what the range being referred
to is?

--

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