Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default ** 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default ** 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default ** 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting Madness JSnow Excel Discussion (Misc queries) 5 February 11th 09 05:52 PM
Formula Madness IoHeFy Excel Discussion (Misc queries) 2 January 4th 07 01:16 PM
AutoFit Madness Josh Sale Excel Programming 2 May 10th 05 12:22 AM
VBA Names madness Jag Man Excel Programming 2 December 30th 03 12:57 AM
More Macro Madness Josh in Tampa Excel Programming 5 October 24th 03 11:14 PM


All times are GMT +1. The time now is 10:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"