Consulting

Results 1 to 13 of 13

Thread: Customize a Formula Based on User Input

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Jun 2004
    Posts
    16
    Location

    Customize a Formula Based on User Input

    I am new to VB ( so be nice <G> )and I am hoping someone can help solve a problem I can?t figure out.
    What I am trying to do is to customize a formula based on input from a user. Can anyone suggest how I can take the input that I have get from the user and plug it into and write a formula into a cell. It is important that the formula be written to a cell rather than doing the If statement with vb.

    Here is the formula. #REF will equal the input that was given by the user.


    PHP Code:
    =IF(#REF!G2>79,"Discharge",IF(#REF!G2>71,"Final",IF(#REF!G2>63, "Second", IF(#REF!G2>55,"First",IF(#REF!G2>31," Informational",""))))) 

    Here is a test script that I am using.

    Sub TEST()
    MyInput = InputBox("Enter Sheet Name")
    Sheets("Home").Select
    Range("k1").Select
    ActiveCell.FormulaR1C1 = _
    "=IF(" & MyInput & "!G2>79,""Discharge"", _
    IF(" & MyInput & "!G2>71,""Final""," & "IF(" & MyInput & "!G2>63, _
    ""Second"", IF(" & MyInput & "!G2>55,""First""," & _
    "IF(" & MyInput & "!G2>31,""Informational"","""")))))"
    End Sub




    Here is the result that is being placed in the cell. The text is being placed in the cell but there are quotes around the cell references [ ?G2? ] and this is causing the formula to croak.



    PHP Code:
    =IF(arggg!'G2'>79,"Discharge",IF(arggg!'G2'>71,"Final",IF(arggg!'G2'>63,"Second",IF(arggg!'G2'>55,"First",IF(arggg!'G2'>31,"Informational",""))))) 


    Any help would be greatly appreciated. I have already spent several hours trying to figure things (reading mostly) out for this project and since it is being done on my own time I would like to spend as little time as needed.
    Last edited by Anne Troy; 06-17-2004 at 12:39 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •