July 10th, 2007, 2:45 pm
Works like this: Say you have a file called rates.xls with FX spots from bloomberg along the top. Call that range FXSpotsSay you want that data to go into in another file, update.xls.Make two macros, UpdMacro and openratesbook.First run openratesbook macro-------------------------------------------------------------------------------------------------------------------------------Sub openratesbook() Application.ScreenUpdating = False Application.Calculation = xlCalculationAutomatic Workbooks.Open Filename:="C:\rates.xls" Application.OnTime Now() + TimeValue("00:00:02"), "UpdMacro"'This ontime call will run UpdMacro in 2 seconds. In the meantime, the openratesbook macro ends.End Sub-------------------------------------------------------------------------------------------------------------------------------Sub UpdMacro()Application.ScreenUpdating = FalseWindows("Rates.xls").Activate If IsNumeric(application.min(Sheets("Sheet1").Range(FXSpots))) = False Then Windows("Update.xls").Activate Application.OnTime Now() + TimeValue("00:00:02"), "UpdMacro"'This ontime call kicks off updmacro again in 2 seconds. In the meantime, the current run of UpdMacro ends. In between the macros, the bbe links in 'the sheets are allowd to update. Else'If the data is updated correctly, copy it to the update.xls file and close the other file. Thing = Sheets("Sheet1").Range(FXSpots) Windows("Rates.xls").Close Application.Calculation = xlCalculationManual Windows("Update.xls").Activate Sheets("Sheet1").Range(DataRange) = Thing Application.ScreenUpdating = True End IfEnd Sub
Last edited by
bskilton81 on July 9th, 2007, 10:00 pm, edited 1 time in total.