none
Calling a subroutine in VBA Problem...

    Question

  • When I try to call the SetFormula Subroutine, it gives me an error saying Expected: "=".  I have no idea why.  The routine and the call are below.

     

    SetFormula("=IF(A2=A1,"""",SUMIF(GroupNo, A2,Premium))", "T")

     

    Sub SetFormula(ByVal sCurrCol As String, ByVal sFormula As String)
        Range(sCurrCol & "2").Select
        ActiveCell.Formula = sFormula
        Selection.Copy
        Range(sCurrCol & "2", sCurrCol & iLower).Select
        ActiveSheet.Paste
        Range(sCurrCol & "1", sCurrCol & iLower).Select
        Coloring
    End Sub

     

    Thanks in advance,
    cboshdave

    Tuesday, April 08, 2008 4:04 PM

Answers

  •  

    I was able to get the subroutine to run by inserting the following to the click event of a command button...

     

    Code Snippet

    Call SetFormula("=IF(A2=A1,"""",SUMIF(GroupNo, A2,Premium))", "T")

     

     

    Without "Call" I experienced the same error as you.
    Tuesday, April 08, 2008 5:02 PM

All replies

  •  

    I was able to get the subroutine to run by inserting the following to the click event of a command button...

     

    Code Snippet

    Call SetFormula("=IF(A2=A1,"""",SUMIF(GroupNo, A2,Premium))", "T")

     

     

    Without "Call" I experienced the same error as you.
    Tuesday, April 08, 2008 5:02 PM
  • It definitely works now.  I am just baffled as to why I put call in sometimes and without any parameters, it works without call.  As long as I am moving forward I guess!!    Thanks!!

     

    Tuesday, April 08, 2008 7:02 PM