cancel
Showing results for 
Search instead for 
Did you mean: 

Analysis for excel and excel macros - Only comments may appear after End Sub

amrita_goswami
Participant
0 Kudos

Hi All,

We are using AFO Version 2.4 to execute BPC Input Forms.

In the Form we have used buttons with VBA Macros.

My macro code is as follows:

Public Sub Save()
Dim lResult As String
Dim i As Integer

If MsgBox("Do you want to Save the Work Status changes?", vbYesNo, "Selection") = vbNo Then
Exit Sub

Else:
Range("F1").value = " "
lResult = Application.Run("SAPExecutePlanningSequence", "PS_1")
If Range("F1").value = "X" Then
IResult = Application.Run("SAPExecuteCommand", "PlanDataSave")
ElseIf Range("F1").value = "Y" Then

lResult = Application.Run("SAPExecuteCommand", "PlanDataReset")

MsgBox ("Central Admin Lock preventing SFIN & CCM Work Status changes.")
End If

End If
End Sub

Sometimes this code runs without issues.

On certain occasions it gives the message 'Only comments are allowed after end Sub' and goes into debug mode. I have checked that there are no blank lines in the code after End Sub.

On other occasions it goes into restart mode.

Please let me know why this may be happening or if you have experienced the same.

Excel and Analysis for Office that I am using are from within Citrix.

Thanks in Advance

Amrita

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member186338
Active Contributor
0 Kudos

In general I can recommend using full object declaration:

Not:

Range("F1").value

But:

Thisworkbook.Worksheets("SheetName").Range("F1").Value

P.S. It's better to use code button to post code - will be readable!