Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Accessing multiple workbooks through a macro


Hi guys,

Just so that you know in advance, I am a beginner at writing macros. I
fact, this is the first macro I've tried to write. Basically I have tw
workbooks and I would like to access both of them through a macro tha
I plan on running on one of the workbooks. I'm not even sure where t
look, and I know the first workbook can be accessed throug
ThisWorkbook, but I'm not sure how to get to the other one. Can anyon
help? Thanks in advance.

PS - Both workbooks are open in Excel and if possible I would like t
be able to access a cell selection I have made in the second workbook
but it is not imperative.

Rama

--
Raman32
-----------------------------------------------------------------------
Raman325's Profile: http://www.excelforum.com/member.php...fo&userid=2474
View this thread: http://www.excelforum.com/showthread.php?threadid=38315

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Accessing multiple workbooks through a macro


The easiest way to see how to do things is to use the macro recorder.
This will generate a macro for you with all the relevant properties and
methods.

You can then use this as a base to write fully functional code that
accepts parameters and all the other bells and whistles you can put in
yourself (A good bookm on VBA would help).

To access the recorder, use -Tools-Macro-Record New Macro-. To
access the Vb editor to see the monster you've created use
-Tools-Macro-VB Editor-.

Regards

Rich


--
Rich_z
------------------------------------------------------------------------
Rich_z's Profile: http://www.excelforum.com/member.php...o&userid=24737
View this thread: http://www.excelforum.com/showthread...hreadid=383159

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Accessing multiple workbooks through a macro


suppose what a.xls is the workbook which has the macro, and b.xls is the
workbook you want to access, there is two ways to code depending on
b.xls file is opened or it is not opened

if b.xls is opened

then you can access by using:
workbooks("b.xls").activate
then you can directly go into the worksheets
worksheets("Sheet1").select
T=RANGE("A2").VALUE

if b.xls is not opened

then you have to open it to access the workbook, you can open it using
macro code, let say that b.xls is in c:\

then
Workbooks.Open Filename:="c:\b.xls" 'opens the file
and then follow the previous code
workbooks("b.xls").activate
then you can directly go into the worksheets
worksheets("Sheet1").select
T=RANGE("A2").VALUE

you can save and close the workbook by using
workbooks("b.xls").save
workbooks("b.xls").close


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=383159

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Accessing multiple workbooks through a macro


Thanks, that fixed it. One more question, sorry. In one of th
workbooks, I have multiple sheets with the format String-1, String-2
String-3, etc. I want to access them each in turn through a for loop
Can I simply have a counter and access the worksheet by doin
Worksheets("String-" + counter).Select

--
Raman32
-----------------------------------------------------------------------
Raman325's Profile: http://www.excelforum.com/member.php...fo&userid=2474
View this thread: http://www.excelforum.com/showthread.php?threadid=38315

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
Multiple Workbooks using same macro Bing59 Excel Discussion (Misc queries) 4 January 24th 10 03:38 AM
Need Help Creating a Macro Multiple Workbooks to One Howeecow Excel Worksheet Functions 1 June 7th 07 06:20 PM
How do I run a macro program for multiple workbooks at one time? Marcelino Excel Programming 1 June 27th 05 10:03 PM
Help with Macro (copying data from multiple workbooks) Tim Harding Excel Discussion (Misc queries) 1 February 5th 05 10:37 PM
Opening Multiple Workbooks from a macro with a twist Doug Excel Programming 2 December 16th 04 08:05 PM


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