none
Converting Excel Formula to VBA code RRS feed

  • Question

  • I have a formula that works in a cell but i would like to do it using VBA. Because i need the cell to register as empty to start.

    =IF(C8>0,IF(OR(C8="Work",C8="Off"),(+COUNTIF(C7:AF7,"Mo")*36+COUNTIF(C7:AF7,"Tu")*36+COUNTIF(C7:AF7,"We")*36+COUNTIF(C7:AF7,"Th")*36+COUNTIF(C7:AF7,"Fr")*36),""),"")

    Wednesday, November 19, 2014 1:55 AM

Answers

  • Hi NYYFAN,

    For IF and OR function:

    If Range(“C8”).Value=”Work” Or Range(“C8”).Value=”Off” Then
    
    Else
    
    End If
    

    For COUNTIF function:

    Application.WorksheetFunction.CountIf(Range(“C7:AF7”,”Mo”)

    On the other hand, to specify formula, you could use Range.Formula property.

    Best Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 20, 2014 9:28 AM
    Moderator