Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Multiple Workbooks using same macro | Excel Discussion (Misc queries) | |||
Need Help Creating a Macro Multiple Workbooks to One | Excel Worksheet Functions | |||
How do I run a macro program for multiple workbooks at one time? | Excel Programming | |||
Help with Macro (copying data from multiple workbooks) | Excel Discussion (Misc queries) | |||
Opening Multiple Workbooks from a macro with a twist | Excel Programming |