At the moment my spreadsheet reads financial data. I would like to programmatically dump this 开发者_如何学Cto CSV every second. How can I do this in VBA?
Something like this should work:
Sub SetTimeout()
Application.OnTime Now + TimeValue("00:00:30"), "SaveAsCSV"
End Sub
Sub SaveAsCSV()
Calculate
ActiveWorkbook.SaveAs Filename:="book1.csv", FileFormat:=xlCSV, CreateBackup:=False
Call SetTimeout
End Sub
Just call SetTimeout()
whenever you want to start saving and it will do so every 30 seconds from then on (hence the Now + TimeValue("00:00:30")
part)
精彩评论