+ Reply to Thread
Results 1 to 2 of 2

Adding two cells then dividing by another

Hybrid View

  1. #1
    Registered User
    Join Date
    01-20-2007
    Posts
    15

    Adding two cells then dividing by another

    I'm trying to create a sheet that will maintain a running average of my score when I'm playing darts.

    B2 = Where I input my score
    B3 = Displays my average
    B4 = +1 just gets added here everytime I click the button.

    The part where I try to define B3 as being B2 + B3 / B4 is the problem.

    Private Sub CommandButton1_Click()
        Range("B4").Value = Range("B4").Value + 1
        Range("B3").Value = Range("B2").Value + Range("B3").Value / Range("B4")
        Range("B2").Select
        Selection.ClearContents
        Range("B2").Select
    End Sub
    Last edited by KJC; 03-25-2013 at 08:07 PM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Adding two cells then dividing by another

    Keep a running total and count to calculate the average.

    Private Sub CommandButton1_Click()
        
        Range("B3").Value = Range("B2").Value + Range("B3").Value   'Total
        Range("B4").Value = Range("B4").Value + 1                   'Count
        Range("B5").Value = Range("B3").Value / Range("B4").Value   'Average
        
        Range("B2").ClearContents
        Range("B2").Select
        
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1