+ Reply to Thread
Results 1 to 1 of 1

Copy data from closed workbook

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Copy data from closed workbook

    Hello:

    Please refer to attached sheets.

    I need a VB Code to perform following.

    Dated data files will be in C:\Temp\ddmmyy_Sales_PLU.xls
    Currently i have file : 050115_Sales_PLU.xls

    I need to extract data from 050115_Sales_PLU.xls and paste in Book1.xls as shown

    Join data from column E and F and put in column A

    I have manually pasted as an example.

    Please let me know if you have any questions.
    Thanks.

    Note :

    I have tried writing the code as below but it is giving error.

    Sub ExtractData()
    
        Dim ClosedWkb As Variant
        Dim ColsCnt As Long
        Dim RowsCnt As Long
        Dim SrcRng As Range
        Dim xl As New Excel.Application
        Dim xlW1 As Excel.Workbook
        Dim x2 As New Excel.Application
        Dim x2w2 As Excel.Workbook
        Dim FilePath1 As String
    
        Set wshTarget = ActiveSheet
        FilePath1 = "C:\Temp\"
        ClosedWkb = FilePath1 & "050115 RSA_Menu Mix By Major Minor Detail" & ".xls"
        Stop
        Application.ScreenUpdating = False
        Set x1w1 = xl.Workbooks.Open(ClosedWkb)
         Stop
        Set SrcRng = xlW1.Sheets("Sheet1").Range("E5:E34")
        ColsCnt = SrcRng.Columns.Count
        RowsCnt = SrcRng.Rows.Count
        wshTarget.Range(A & "1").Resize(RowsCnt, ColsCnt) = SrcRng.Value
    
         x1w1.Close False
        
        ' free memory
        Set x1w1 = Nothing
        Set x1 = Nothing
    End Sub
    Riz
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 03-27-2014, 12:38 PM
  2. [SOLVED] Code to copy data from a closed workbook and paste in active workbook using named range.
    By paullie1912 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-28-2014, 02:38 AM
  3. Copy Data from Closed workbook (bbb.xls) to Open workbook (aaa.xls) (Part 2)
    By alexnkc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-23-2013, 02:06 AM
  4. [SOLVED] Copy Data from Closed workbook (bbb.xls) to Open workbook (aaa.xls)
    By alexnkc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-22-2013, 03:24 AM
  5. VBA to copy data from closed workbook to open workbook
    By Anil2007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-27-2011, 12:30 PM

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