Results 1 to 18 of 18

Copy data from another worksheet without open that workbook

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    165

    Copy data from another worksheet without open that workbook

    Hi
    I have this VBA that work for me, but I want to update my sheet without opening the other file. any idea how i can do this?
    thanks in advance.

    Option Explicit
    Sub test()
        Dim wb As Workbook, wb2 As Workbook
        Dim ws As Worksheet
        Dim vFile As Variant
    
        'Set source workbook
        Set wb = ActiveWorkbook
        'Open the target workbook
        vFile = Application.GetOpenFilename("Excel-files,*.xls", _
            1, "Select One File To Open", , False)
        'if the user didn't select a file, exit sub
        If TypeName(vFile) = "Boolean" Then Exit Sub
        Workbooks.Open vFile
        'Set targetworkbook
        Set wb2 = ActiveWorkbook
    
        'For instance, copy data from a range in the first workbook to another range in the other workbook
        wb.Worksheets("Sheet1").Range("b5:g42").Value = wb2.Worksheets("POMaster").Range("b5:g42").Value
    End Sub
    Last edited by robrobet; 07-04-2013 at 02:04 PM.

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