LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Copy from one open workbook to another?

I asked the following question a few days ago and was given a link to a Ron
Debruin page (with more code I didn't understand). What I would prefer is for
someone to please comment on why my code below doesn't work. I am trying to
learn Excel VBA and considering that the help that comes with the program is
only marginally better than useless, I was hoping for an explanation here.

Please...no more links to Ron Debruin. I'm sure that code is genius, but it
hardly helps if I don't understand it.

Here goes....

-------------------------------------------------------------------------
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
 
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
Copy from one open workbook to another? Geoff[_3_] Excel Programming 3 November 22nd 09 05:41 PM
Copy Range from Open Workbook to Active Workbook Forgone Excel Programming 0 July 17th 09 01:46 AM
Copy data from another workbook to any open workbook Coder1215 Excel Programming 3 January 2nd 09 01:11 PM
How to open a workbook as a copy? c mateland Excel Programming 5 March 15th 07 08:00 PM
Does Workbook need to be open to copy to..from vba Dale[_15_] Excel Programming 1 December 11th 04 05:31 PM


All times are GMT +1. The time now is 07:41 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"