Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Populate excel file B with Columns/data from Excel File A

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
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
import data from txt file to an existing excel file shaji Excel Discussion (Misc queries) 1 September 12th 09 04:15 PM
How do I merge two excel file data (no changes made to the file)? Gem Excel Discussion (Misc queries) 1 January 29th 09 02:19 PM
How do you populate an HTML form with EXCEL or DB file? Is it possible? [email protected] Excel Discussion (Misc queries) 0 January 20th 08 02:38 PM
merging data from 1 excel file, into a master excel file motSwE New Users to Excel 2 September 13th 06 06:39 PM
Open delimited text file to excel without changing data in that file zohanc Excel Programming 1 October 3rd 03 01:06 AM


All times are GMT +1. The time now is 12:15 PM.

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"