Results 1 to 4 of 4

Copying from another workbook into current workbook

Threaded View

  1. #1
    Registered User
    Join Date
    08-02-2012
    Location
    Leeds
    MS-Off Ver
    Excel 2003
    Posts
    2

    Copying from another workbook into current workbook

    Hi I am trying to create a macro that copies data from a workbook and then pastes special and adds the data to cells in the current workbook. Also I'd like it to close the workbook that the macro opens once it has done the copying.

    My code so far is as follows but It does not really work. Please help ASAP.

    Sub RetrieveData()
    Dim filetoopen As String
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim Book As Workbook
    '
    'Get User to select file to open
    '
    filetoopen = Application _
    .GetOpenFilename("XL Files (*.xls), *.xls")
    On Error Resume Next
    
    Set wb = Workbooks.Open(filetoopen, True, True)
    
    Sheets("Summary").Activate
    Range("C31:D45").Select
    Range("C31:D45").Copy
    ActiveWorkbook.Worksheets("Summary").Activate
    Selection.PasteSpecial Paste:=Values, Operation:=Add, SkipBlanks:= _
    False, Transpose:=False
    Application.CutCopyMode = False
    
    End Sub
    Last edited by jigypeper; 08-03-2012 at 05:19 AM.

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