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: 1
Default switching between workbooks...


Hi,

I have created a workbook (workbook 1) with some buttons (forms) which,
when clicked, opens another workbook (workbook 2) and then runs some
macros. All the macros do is copy multiple ranges of data from workbook
1 and paste the data into various cell locations in workbook 2. In the
macros i do not want to have to specify the workbook name to paste data
into, as the workbook i am opening will not always be the same name. i
have tried the following but it does not seem to work:

~~~
Sub Button_click()

Workbook.open("xxxx.xls")
' next i have specified a constant (target) to use rather than the name
of the workbook
target = Activeworkbook.name
' next i run the macros or copying
run ("macro 1")
run ("macro 2")
etc
~~~


now in the macro i have the following code:
~~~~~
workbooks("workbook 1.xls").Acivate
Sheets("sheet1").Select
Range("A1:H7").Select
Selection.copy
workbooks(target).Activate
Sheets("sheet 5").select
Range("I9").Select
Selection.paste
~~~~~

that is roughly what is happening.
I hope that what i am trying to do is clear. Please let me know where i
am going wrong or whether there are any alternative methods i can use.

Thanks in advance


--
safdarhassan
------------------------------------------------------------------------
safdarhassan's Profile: http://www.excelforum.com/member.php...o&userid=37424
View this thread: http://www.excelforum.com/showthread...hreadid=571011

 
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
Switching between Workbooks Doekoe Excel Discussion (Misc queries) 0 May 5th 08 10:54 AM
Switching between workbooks Jim Excel Discussion (Misc queries) 5 July 28th 07 03:19 AM
Switching tabs Gor_yee Excel Discussion (Misc queries) 1 February 15th 07 10:57 AM
Switching between Worksheets Dave Peterson[_3_] Excel Programming 0 September 8th 04 02:42 AM
Switching Workbooks in vbscript Joe[_3_] Excel Programming 1 August 25th 04 09:09 PM


All times are GMT +1. The time now is 03:46 AM.

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"