+ Reply to Thread
Results 1 to 8 of 8

Adding numbers from a single cell

Hybrid View

  1. #1
    Registered User
    Join Date
    09-18-2008
    Location
    Kansas
    Posts
    5

    Adding numbers from a single cell

    I need help with a formula. I need to add different numbers from a single cell. For example I need to be able to enter an 8, delete the 8, then enter an10 in the same cell and the total to come up as 18. Any help would be greatly appreciated.

  2. #2
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    This can be done using VBA. This basic code can do the trick. Adapt it as necessary.



    Dim val As Double
    
    Private Sub Worksheet_Change(ByVal Target As Range)
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
            
            If IsNumeric(Target) Then
            Target = Target + val
            End If
                
            .ScreenUpdating = True
            .EnableEvents = True
        End With
    End Sub
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If IsNumeric(Target) Then
            val = Target.Value
        End If
    End Sub

  3. #3
    Registered User
    Join Date
    09-18-2008
    Location
    Kansas
    Posts
    5
    I'm relatively new to excel and I'm not sure how to enter that information into Excel. I have never used VBA before.

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

  5. #5
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    Quote Originally Posted by hri1428 View Post
    I'm relatively new to excel and I'm not sure how to enter that information into Excel. I have never used VBA before.
    If you are new to VBA, your best bet is to post a sample of your workbook so we can see your formatting and layout. This is important because it will help us trap for errors and troubleshoot any potential problems before they occur.

    If you would prefer to just put the code in yourself, right click on the sheet tab that you want the code to be applied to (ie, Sheet1). One of the options should be View Code. Once you click that, the VBE will open up and a dialog box will have the focus. Simply copy and paste my code into the dialog box.

    Let me know if it works.

  6. #6
    Registered User
    Join Date
    09-18-2008
    Location
    Kansas
    Posts
    5
    How do I apply the code to the specific cell or cells that I want the sum in?

  7. #7
    Registered User
    Join Date
    09-18-2008
    Location
    Kansas
    Posts
    5
    For example I need to be able to put 8 in A1, 7 in A2 and have the total of 15 in A3. I then need to be able to go back and delete the 8 and the 7 and have the total in A3 remain 15. Then I need to be able to put a 7 in A1 an 8 in A2 and have the total in A3 be 30.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Adding numbers within a total
    By michaelas in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-27-2008, 04:51 PM
  2. read cell content and use with Hyperlinks.Add Cell
    By apoc [t.i.m.] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-04-2007, 10:02 AM
  3. using cell content to reference a worksheet tab name in second workbook
    By Conor in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-29-2007, 09:32 AM
  4. Keep cell adding after data is deleted
    By pinhead1 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 06-07-2007, 05:15 PM
  5. Linking multiple cell data to a single cell
    By matt92 in forum Excel General
    Replies: 5
    Last Post: 03-14-2007, 01:54 AM

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