![]() |
** Range Copying Madness **
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 |
** Range Copying Madness **
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) "ric_deez" wrote in message oups.com... 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 |
** Range Copying Madness **
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 |
All times are GMT +1. The time now is 02:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com