Consulting

Results 1 to 11 of 11

Thread: Solved: Formula help

  1. #1
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location

    Solved: Formula help

    I need to calculate a total. for instance, a1*b1 then take the answer and add it to what was in b1 to begin with. The only way i can think of is a two step process. Thanks

  2. #2
    Knowledge Base Approver
    The King of Overkill!
    VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Austen,

    So you want B1 to be B1+(A1*B1) ? So if A1 contains 2 and B1 contains 4, you want B1 to then contain 12?

    Unfortunately Paste Special doesn't allow you to multiply and add, so you would have to use a third column, then paste special the values back into B:
    =B1+A1*B1

    Matt

  3. #3
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Thanks buddy. I was hping not to have to do it that way. BTW, on an unrelated subject what do you have to do to re-install te MSDN collection?

  4. #4
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Paste special would have allowed you to Add something to B, or multiply A by B, but unfortunately for both operations you'd have to use the formula.

    Not exactly sure about the MSDN thing, I would assume it would be on the VB CD. It isn't anything you can download that I'm aware of

  5. #5
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    ok thanks

  6. #6
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    [VBA]Sub DoCalculation()
    [B1] = [B1+(A1*B1)]
    End Sub[/VBA]
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  7. #7
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Thanks John

  8. #8
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    It's easier with VBA (you avoid the circular reference problem). You could also make it a change event E.G.
    [VBA]
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 2 Then
    Application.EnableEvents = False
    [B1] = [B1+(A1*B1)]
    Application.EnableEvents = True
    End If
    End Sub
    [/VBA]
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  9. #9
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Or, to apply it to the entire column, [VBA]Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 2 Then
    Application.EnableEvents = False
    Target = Evaluate(Target + (Range("A" & Target.Row) * Target))
    Application.EnableEvents = True
    End If
    End Sub[/VBA]
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  10. #10
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    What exactly do you want installed with the MSDN Collection? Do you have the DVDs or web access to the site?

  11. #11
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Hi Zack. Im not really sure. My predicesor was a, well, I cant say that on here. Anyway he re engineered a bunch of Access code into SQL Server. Now the powers that be and me want something that is not so tied to SQL, stored procedures and some other junk. It is that reference (VB T-SQL) that the save function is looking for. Cant find it and as far as I know is not downloadable from MSN.

Posting Permissions

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