HDR hardman resources limited

excel experts required, page-5

  1. 4,479 Posts.
    lightbulb Created with Sketch. 2
    BTW, I think a limited version of VB is now distributed in the MS-Office packs and is usually accessed by pressing Alt+F11(or clicking on the menu: Tools->Macro->VB editor).

    For your sample, you would enter something like this in the VB code module(be aware, Evaluate may be a reserved word so in this example I'll call it EvaluateX).
    My VB is very rusty so I'll just write a basic pseudocode.(it's not a very powerfull programming language at all IMHO, but it's MS's plaything so we have to deal with it lol)


    Function EvaluateX(CellCmd As String)
    Dim CellValA As Variant
    Dim CellValB As Variant
    Dim MathsSymbol As Long

    {Write code that scans the string sent to the function and stores the sum type(eg +,-,* etc), and the two cell values into the defined variables}

    {You would then most likely have several different blocks of code depending which maths symbol is being used, separated by an if/case statement, for example in the + symbols code you would have something like}

    EvaluateX = CellValA + CellValB

    {and the - symbols code you would have something like}

    EvaluateX = CellValA - CellValB

    End Function


    Then in Excel you would call it by entering into the desired cell "=EvaluateX(A1)"
 
watchlist Created with Sketch. Add HDR (ASX) to my watchlist

Currently unlisted public company.

arrow-down-2 Created with Sketch. arrow-down-2 Created with Sketch.