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
Bookmarks