Hi,
I have a macro that extracts data from a source workbook. The data is owerwritten every time that I use the macro. Now I have a graph that everytime I use the macro does not update with the new data, Is there a clever way to do that?
The code for extracting from the workbook is the following:
Sub Extract()
Dim myFileName As Variant
Dim SourceWkbk As Workbook
Dim CurrentWkbk As Workbook
Dim testWks As Worksheet
ActiveWorkbook.Sheets("CURRENCIES").Select
ActiveWindow.SelectedSheets.Delete
myFileName = Application.GetOpenFilename("Excel files,*.xls")
If myFileName = False Then
Exit Sub 'user hit cancel
End If
Set CurrentWkbk = ActiveWorkbook
Set SourceWkbk = Workbooks.Open(Filename:=myFileName)
Set testWks = Nothing
On Error Resume Next
Set testWks = SourceWkbk.Worksheets("CURRENCIES")
On Error GoTo 0
If testWks Is Nothing Then
MsgBox "Missing the worksheet!"
Else
testWks.Copy _
before:=CurrentWkbk.Worksheets(2)
End If
SourceWkbk.Close savechanges:=False
end sub
Display More
Robert