Consulting

Results 1 to 6 of 6

Thread: Formula in a Control

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Formula in a Control

    I am trying to enter a formula into a control but I can't get it to work. I tried the help and the forums here and can't seem to find a solution.

    Here is what I tried:

    [VBA]Me.lblTurnOver.Caption = Formula((365) / ((("B2") / 4) / (Me.WorkingCapital1.Value)))[/VBA]

    the Formula is the (365/cell"B2"/4)/Control(WorkingCapital1)

  2. #2
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    here's an example that puts the formula in a cell....see if you can adapt it:
    [VBA]With [E2]
    .Formula = "=IF(D2=F2,D2,IF(ISBLANK(D2),F2,IF((LEN(SUBSTITUTE( TRIM(D2),CHAR(32),CHAR(32)&CHAR(32)))-LEN(TRIM(D2))+1)=1,LOOKUP(D2,Sheet2!$D$2:$D$110,Sh eet2!$A$2:$A$110),IF(OR(D2=""CONNIE"",D2=""DARLENE"",D2=""MICHAEL"",D2=""MA RIANO"",D2=""JAMES""),F2,D2))))"
    End With[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    Steve,

    I think I am getting closer:

    [vba]Me.lblTurnOver.Caption = "=(365) / ((Range("B2") / 4) / (Me.WorkingCapital1.Value))"[/vba]

    tell me if I am on the right track and where to what direction to head in please. I tried this and it still doesn't work

  4. #4
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Daniel,
    I'll be honest...I'm not sure you can assign a formula to a control like this...why not use a cell reference?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    I guess I will have to do the formula in a cell and then enter it in?

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,730
    Location
    I'm guessing that you want to put the result of the formula in the label's caption ??? Not tested, but something like this maybe???

    x = 365 / range ("B2").value
    x = x / 4
    x = x / Me.WorkingCapital1.Value

    Me.lblTurnOver.Caption = CStr (x)


    Paul

Posting Permissions

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