+ Reply to Thread
Results 1 to 2 of 2

Code to open a workbook , copy info and return it to another workbook using a cell v.

Hybrid View

  1. #1
    Registered User
    Join Date
    03-04-2008
    Posts
    4

    Code to open a workbook , copy info and return it to another workbook using a cell v.

    
    sub mine
    
    Sheets("SITE").Select
        Rows("3:3").Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.ClearContents
    Sheets("Control").Select
     
    Dim Rng As Range, Source As Range, Tgt As Range
    Dim wsD As Worksheet
    Dim WB As Workbook
        
    Set wsD = Workbooks("Returns.xls").Sheets("Control")
    Set Rng = Range("C9")
        
    If Not Rng.Value = vbNullString Then
            
    Set WB = Workbooks.Open("P:\CET - Employee Engagement\Sourcing & Monitoring\" & Rng.Value)
    
    With WB.Sheets("CallData")
    Set Source = Range(.Cells(3, 1), .Cells(Rows.Count, 1).End(xlUp)).Resize(, 256)
    End With
    
    Set Tgt = Workbooks("Returns.xls").Sheets("SITE").Cells(Rows.Count, 1).End(xlUp).Offset(1)
    
    Source.Copy Tgt
    
    Application.DisplayAlerts = False
    
    WB.Close False
    Application.DisplayAlerts = True
    
    End If
    
    End Sub

    Hi this code works perfectly just need a tweek how can I get the workbook which is opened up not to run any macros, because the workbook has an on open and an on close macro.

  2. #2
    Valued Forum Contributor
    Join Date
    08-26-2006
    Location
    -
    MS-Off Ver
    2010
    Posts
    388
    Use this statement before opening the workbook and set to True after closing.
    Application.EnableEvents = False

+ 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