** Range Copying Madness **

  • Thread starter Thread starter ric_deez
  • Start date Start date
R

ric_deez

Hi there,

I have a spreadsheet where I need to copy certain values around so
that:
Column D is copied to Column A
Column E is copied to Column C
Column K is copied to Column D
Column L is copied to column E

I have the following script, where tRow is a reference to the last row
containing data. The data starts in row 8, wkDst is a reference to the
Worksheet

tmpRgeText = "D8:D" & tRow
wkDst.Range(tmpRgeText).Copy Destination:=wkDst.Range("A8")

tmpRgeText = "E8:E" & tRow
wkDst.Range(tmpRgeText).Copy Destination:=wkDst.Range("C8")

tmpRgeText = "K8:K" & tRow
wkDst.Range(tmpRgeText).Copy Destination:=wkDst.Range("D8")

tmpRgeText = "L8:L" & tRow
wkDst.Range(tmpRgeText).Copy Destination:=wkDst.Range("E8")

The problem is that columns A and D end up with the contents of column
K and columns C and E end up with the contents of Column L. I guess
this is happening because both range "handles" end up pointing to the
same object in memory.

Can someone suggest a fix for this? I really would prefer solutions
which don't involve doing this at the cell level (which tends to slow
things down unacceptably). Any suggestions would be greatly
appreciated.

Regards,

Ric
 
Ric,

Testing using your code doesn't do what you suggest for me, apart from
leaving K&L populated, it seems to work fine.

You don't repeat the action by any chance, as that would cause it to happen.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
Hi Bob,

Thanks for checking this out for me. You are right, I was
inadvertently calling this procedure twice... Doh!!! I should have
isolated the code prior to posting... Sorry for wasting your time and
thank you for your assistance.

Regards,

Ric
 

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