Consulting

Results 1 to 5 of 5

Thread: Do Calculation with Form before I enter on worksheet

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

    Do Calculation with Form before I enter on worksheet

    I created a form for users to enter a number in but now I want need to do a math calculation before I enter it on the spreadsheet. This is what I tried:

    [VBA]Range("B71").formular1c1 = (=PandL2.Interest1.Value*.01)[/VBA]

    PandL2 is the form and interest1 is the textbox

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    [vba]Range("B71").FormulaR1C1 = (Interest1.Value * 0.01)[/vba]
    what's up with the = sign?
    this isn't formatted...it only puts a number in B71
    if you use 100 in the textbox it will return only a 1
    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
    I am doing the formating on the next line now

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    To get a value from a form's control, use

    [vba]

    Range("B71").Value PandL2.Interest1.Value*.01
    [/vba]

    but the form will still need to be loaded, otherwise it fails.

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    [VBA]Range("B71").FormulaR1C1 = Format(CDbl(Interest1.Value) * 0.01, "0.00%")[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

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