![]() |
Copy from one open workbook to another?
I have a workbook that gets a lot of use by others. Periodically, I
distribute revisions so I wrote some code to clear all my data (inventory levels, etc.) but leave the base sheet data (product attributes, etc.), That was relatively easy. Now I want to be able to take a cleaned file and put my data back in which is stumping me because I don't really know how to switch back and forth between sheets. One wrinkle is that I don't want to refer to the actual filenames in the code since they do change. So I tried this: iBlank = 1 iData = 2 Windows(iData).Activate Range("C2:C4").Copy Windows(iBlank).Activate Range("C2:C4").Select ActiveSheet.Paste I will always be running this from the empty datafile, so if I'm not mistaken that will have Index = 1 and the one I am copying from will have Index = 2 if I understand this correctly. There are many ranges that need to be copied. So it would seem to me that the above: * activates the datafile * copies the range in the datafile * activates the blankfile * pastes in the range in the blankfile The data gets copied and I see the marching ants. But it does not get copied to the blankfile. I think it just copies it right back to the datafile. TIA...Geoff |
Copy from one open workbook to another?
Geoff,
have a read of Ron's article. http://www.rondebruin.nl/copy1.htm -- jb "Geoff" wrote: I have a workbook that gets a lot of use by others. Periodically, I distribute revisions so I wrote some code to clear all my data (inventory levels, etc.) but leave the base sheet data (product attributes, etc.), That was relatively easy. Now I want to be able to take a cleaned file and put my data back in which is stumping me because I don't really know how to switch back and forth between sheets. One wrinkle is that I don't want to refer to the actual filenames in the code since they do change. So I tried this: iBlank = 1 iData = 2 Windows(iData).Activate Range("C2:C4").Copy Windows(iBlank).Activate Range("C2:C4").Select ActiveSheet.Paste I will always be running this from the empty datafile, so if I'm not mistaken that will have Index = 1 and the one I am copying from will have Index = 2 if I understand this correctly. There are many ranges that need to be copied. So it would seem to me that the above: * activates the datafile * copies the range in the datafile * activates the blankfile * pastes in the range in the blankfile The data gets copied and I see the marching ants. But it does not get copied to the blankfile. I think it just copies it right back to the datafile. TIA...Geoff |
Copy from one open workbook to another?
Can anyone comment one why my code doesn't work?
"john" wrote: Geoff, have a read of Ron's article. http://www.rondebruin.nl/copy1.htm -- jb "Geoff" wrote: I have a workbook that gets a lot of use by others. Periodically, I distribute revisions so I wrote some code to clear all my data (inventory levels, etc.) but leave the base sheet data (product attributes, etc.), That was relatively easy. Now I want to be able to take a cleaned file and put my data back in which is stumping me because I don't really know how to switch back and forth between sheets. One wrinkle is that I don't want to refer to the actual filenames in the code since they do change. So I tried this: iBlank = 1 iData = 2 Windows(iData).Activate Range("C2:C4").Copy Windows(iBlank).Activate Range("C2:C4").Select ActiveSheet.Paste I will always be running this from the empty datafile, so if I'm not mistaken that will have Index = 1 and the one I am copying from will have Index = 2 if I understand this correctly. There are many ranges that need to be copied. So it would seem to me that the above: * activates the datafile * copies the range in the datafile * activates the blankfile * pastes in the range in the blankfile The data gets copied and I see the marching ants. But it does not get copied to the blankfile. I think it just copies it right back to the datafile. TIA...Geoff |
Copy from one open workbook to another?
No one? Please. I am trying to understand this. Linking me to a site with
more code I don't understand doesn't help me at all. "Geoff" wrote: Can anyone comment one why my code doesn't work? |
All times are GMT +1. The time now is 03:32 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com