cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

VBA to exit save macro if system produces "there is no data to save" message

Former Member
0 Likes
472

Hi Experts,

Would appreciate a lot your help with one question. I am working on a template that does the following: 1. Tab A submits data to the system; 2. Tab B is retrieving calculated values from the system. There's a validation built in to compare values between Tab A and Tab B. Thus, I have a macro that saves data to the system from Tab A, then goes to Tab B and refreshes it for validation purposes. However, if data on Tab A has not been changed, the system produces a message "There's no data to save", then Tab B is getting refreshed. I'd like to add a condition to the macro, so that if system produces the message "There's no data to save", the macro would be exited instead of proceeding with Tab B refresh. Is there a way to accomplish this? (I don't know how to capture the system message "There's no data to save" in VBA as a condition to trigger macro exit). Any help would be greatly appreciated!

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Likes

Hi Mariya,

Look on AFTER_SAVE event function - it will not trigger if "There's no data to save". Just change some global variable in this function and check this variable in your code. If it's not changed - then "There's no data to save".

Vadim

former_member186338
Active Contributor
0 Likes

Like here:

Dim epm As New FPMXLClient.EPMAddInAutomation

Public blnSaved As Boolean

Function AFTER_SAVE()

blnSaved = True

AFTER_SAVE = True

End Function

Public Sub SaveD()

blnSaved = False

epm.SaveAndRefreshWorksheetData

If blnSaved Then

    MsgBox "Data was saved"

End If

End Sub

P.S. This code have to be placed in the new module, not in the worksheet module!!! At least - Function AFTER_SAVE()

Former Member
0 Likes

Works like charm! Thank you so much for your help, Vadim!!!

Answers (0)