Hello,
I have, with help of this forum, gotten my workbook to close without asking to save.
I have done that with this code;
Now, the problem is, that this code disables anybody from saving any changes (and that is good, most of the time).
However, I have 1 sheet and two cells in another sheet that I would like to be able to save, and that revolves around my exchange rates.
I have a command button that I can press to update my exchange rates in a sheet called "exchange rates" and then I have two cells in a sheet called "Prices" which contains the date and time of the last update and who updated it.
But, the code that disables the save function, also does so that I cannot save the new exchange rates and information in "Prices" when I have updated the rates.
Can I put a code into my command button sub, that saves the document when the exchange rates has been updated?
Here is the code for the command button that updates my rates:
I have, with help of this forum, gotten my workbook to close without asking to save.
I have done that with this code;
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Saved = True
End Sub
Now, the problem is, that this code disables anybody from saving any changes (and that is good, most of the time).
However, I have 1 sheet and two cells in another sheet that I would like to be able to save, and that revolves around my exchange rates.
I have a command button that I can press to update my exchange rates in a sheet called "exchange rates" and then I have two cells in a sheet called "Prices" which contains the date and time of the last update and who updated it.
But, the code that disables the save function, also does so that I cannot save the new exchange rates and information in "Prices" when I have updated the rates.
Can I put a code into my command button sub, that saves the document when the exchange rates has been updated?
Here is the code for the command button that updates my rates:
Code:
Sub Update_rates()
Application.ScreenUpdating = False
Sheets("Exchange rates").Visible = True
' Update_rates Macro
If MsgBox("Internet connection needed to update exchange rates. Update now?", _
vbYesNo) = vbNo Then
Sheets("Exchange rates").Visible = xlVeryHidden
Application.ScreenUpdating = True
Exit Sub
End If
Sheets("Exchange rates").Select
Range("A1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("Prices").Select
Sheets("Exchange rates").Visible = xlVeryHidden
Application.ScreenUpdating = True
MsgBox "Exchange rates has been updated from [URL="http://www.x-rates.com/"]Exchange Rates - X-Rates[/URL]"
Range("K7") = Now
Set objAD = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objAD.UserName)
strDisplayName = objUser.DisplayName
Range("K5").Value = (strDisplayName)
End Sub
Last edited: