![]() |
Accessing information from second workbook
I have a situation where I am trying to write a macro for work to handl
printing our schedules. We have a program that ouputs our dail schedules in excel format, and I have written a macro that cleans i up, sorts it, and color codes it. The problem is that now I am looking to make it a better tool for th less computer savvy members in my department. The macro is saved in document called "Day-at-a-Glance Macro.xls" and contains instructions as well as some individual table for customizing. One of thes contains some employee names and the department they work in. Anothe contains the color coding. The macro is designed to work by opening both the macro document, an the schedule data document, so the user can run the macro in the dat document. I have been unable to loop through information in the macr document for use in the data document. Here is the code as I have it so far: Dim wbkPth As String wbkPth = "'[Day-at-a-Glance Macro.xls]Sheet1'!" range(wbkPth & "D18").Activate Do row = ActiveCell.row Call addDpt(first:=range(wbkPth & "D" & row).Value last:=range(wbkPth & "E" & row).Value, dept:=range(wbkPth & "F" row).Value) ActiveCell.Offset(1, 0).Select Loop Unti IsEmpty(Excel.Workbooks(1).Worksheets(1).ActiveCel l.Offset(0, 1)) Can anyone help? Thank you very much :o) -Nic -- Message posted from http://www.ExcelForum.com |
Accessing information from second workbook
I have been working on this all weekend, and still haven't had any luck.
Any suggestions? Thank you very much -Nick --- Message posted from http://www.ExcelForum.com/ |
Accessing information from second workbook
If the other workbook is name Book2.xls and has a sheet on it named sheet1,
then msgbox workbooks("book2.xls").sheets("sheet1").range("a1" ).value will display the value of cell A1 on that sheet. The following will also do it: msgbox workbooks("book2.xls").sheets("sheet1.cells(1,1).v alue The use of Cells(row number, column number) is often easier to use if you need to check a large number of cells: For K = 1 to 5 msgbox workbooks("book2.xls").sheets("sheet1").cells(K, 1).value Next displays the values in 5 cells based on the value of variable K. Robert Flanagan Macro Systems Delaware, U.S. 302-234-9857 http://www.add-ins.com Productivity add-ins and downloadable books on VB macros for Excel "randland " wrote in message ... I have been working on this all weekend, and still haven't had any luck. Any suggestions? Thank you very much -Nick --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 12:48 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com