+ Reply to Thread
Results 1 to 5 of 5

Importing Data from one workbook to another

Hybrid View

  1. #1
    Registered User
    Join Date
    06-03-2008
    Posts
    2

    Importing Data from one workbook to another

    I need to be able to select slave workbooks from inside a master workbook using a expandable explorer style file menu. then once the files are selected import data from specific cells in each.

    the importing of the data should be no problem it just the user friendly method of selecting the files that is the issue!

    Thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello lamgar,

    Welcome to the Forum!

    We will need a little more information about the worksheet layouts in order to help you. It would save time if you can post a copy of the master and one of the slave workbooks for review.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    01-07-2008
    Location
    Northampton, UK
    MS-Off Ver
    version 2212, office 365 enterprise
    Posts
    74
    Here is the code I got from a very helpful person on this forum. I use it to import data from access but I'm sure you can adapt it to your application. This code allows you to browse your computer or network for the file you want to import.

    Sub Import_Tables()
    '
    ' Import ALL tables from Access
    ' Macro recorded 24/01/2008 by Chris Mann
    
    ' Application.ScreenUpdating = False
    
    'Browse to database using prompt
       Dim strPath As String
        Dim vntFile As Variant
        
        strPath = "C:\Documents and Settings\cmann29\My Documents\2007 Test Converter Tool\"
    
        ChDrive strPath
        
        vntFile = Application.GetOpenFilename("Database File *.mdb,*.mdb,All Files *.*,*.*")
        If vntFile = False Then Exit Sub
        
    'Import PPG table from access
        Sheets("PPG").Select
        Columns("A:U").Select
        Selection.Delete Shift:=xlToLeft
        Range("A1").Select
        With ActiveSheet.QueryTables.Add(Connection:=Array( _
            "OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=" & vntFile, _
            ";Mode=ReadWrite;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path" _
            , _
            "="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2" _
            , _
            ";Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encryp" _
            , _
            "t Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False" _
            , ""), Destination:=Range("A1"))
            .CommandType = xlCmdTable
            .CommandText = Array("PPG")
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .PreserveColumnInfo = True
            .Refresh BackgroundQuery:=False
        End With
    
    End Sub
    Hope that helps
    Ne auderis delere orbem rigidum meum!

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I8s this what you mean

    Option Explicit
    
    Sub openFile()
        Dim fn
        fn = Application.GetOpenFilename  'can add parameters. See help for details.
        If fn = False Then
            MsgBox "Nothing Chosen"
        Else: Workbooks.Open fn
        End If
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    06-03-2008
    Posts
    2
    thanks got it done!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1