Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is there a way to allow spreadsheet B to programmtically extract selected
columns and formatting from Spreadsheet A. In this scenario I cannot be sure that Spreadhseet A is open. The reason I need to do this is because Spreadsheet is extremely complex and I need to create another spreadsheet view for another department and do not wish to duplicate data. Appreciate any advice Thanks Jason |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you only needed the data there would be a few options, but to extract the
formatting too you will need to get it through automation. Create an object variable to hold and start a new Excel session (will be done invisibly by default, unless you make it visible): Dim XLApp As Excel.Application Dim XLBook As Excel.Workbook Set XLApp = New Excel.Application Set XLBook = XLApp.Workbooks.Open(FileName) ' You can use any regular VBA code here to extract the data you need and ' copy it to your other workbook - just use XLApp or XLBook before any property, ' method, or collection in the "new" session; e.g: XLBook.Sheets("Sheet1").Range("A1:A100").Copy ThisWorkbook.Sheets("Sheet1").Range("A1:A100").Pas teSpecial xlPasteValues ThisWorkbook.Sheets("Sheet1").Range("A1:A100").Pas teSpecial xlPasteFormats ' above copies cells A1 to A100 from XLBook(in hidden Excel session) ' and puts values and then formats in same range of ThisWorkbook ' (the original Excel session) ' When done close the new session and clear out object variables! XLBook.Close False Set XLBook = Nothing XLApp.Quit Set XLApp = Nothing " wrote: Is there a way to allow spreadsheet B to programmtically extract selected columns and formatting from Spreadsheet A. In this scenario I cannot be sure that Spreadhseet A is open. The reason I need to do this is because Spreadsheet is extremely complex and I need to create another spreadsheet view for another department and do not wish to duplicate data. Appreciate any advice Thanks Jason |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
import data from txt file to an existing excel file | Excel Discussion (Misc queries) | |||
How do I merge two excel file data (no changes made to the file)? | Excel Discussion (Misc queries) | |||
How do you populate an HTML form with EXCEL or DB file? Is it possible? | Excel Discussion (Misc queries) | |||
merging data from 1 excel file, into a master excel file | New Users to Excel | |||
Open delimited text file to excel without changing data in that file | Excel Programming |