Results 1 to 8 of 8

NEED HELP - Fix Macro Automatically SUM upper data when entering new data

Threaded View

  1. #1
    Registered User
    Join Date
    04-27-2016
    Location
    US
    MS-Off Ver
    2007
    Posts
    4

    NEED HELP - Fix Macro Automatically SUM upper data when entering new data

    Hi everybody.
    I have a macro, it will automatically add a row and calculate SUM all the data of upper rows when I entering new data.

    But if I add or delete any value in Quantity column from any Group, the SUM row will not correct because it does not plus or minus that value (please view attached file)

    PN9LBOs.png

    So I want this macro will calculate exactly when I add more or delete any value.
    Please help me fix this macro !!! Thank you!!!! And sorry for my bad English.

    Here is my macro

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim so As String
    Dim dg As Long
    dg = Target.Row
    Application.EnableEvents = False
    If Target.Column = 1 And Target.Text <> "" Then
    If Target.Row <= 2 Then Exit Sub
    For i = Target.Row - 1 To 1 Step -1
    If Sheet1.Cells(i, 1) <> "" Then
    so = Sheet1.Cells(i, 1)
    Exit For
    End If
    Next
    Range(Target.Address, Target.Offset(0, 3).Address).Insert Shift:=xlDown
    Sheet1.Cells(dg, 1).EntireRow.Interior.ColorIndex = 35
    Sheet1.Cells(dg, 1).EntireRow.Font.Bold = True
    Sheet1.Cells(dg, 1).EntireRow.Font.Size = 16
    Sheet1.Cells(dg, 1) = "SUM"
    Sheet1.Cells(dg, 3).Formula = Application.WorksheetFunction.Sum(Range(Sheet1.Cells(dg - 1, 3), Sheet1.Cells(i, 3)))
    Sheet1.Cells(dg + 1, 2).Select
    End If
    Application.EnableEvents = True
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Possible to transform automatically while entering data?
    By pblge in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-30-2014, 02:24 PM
  2. Entering data into the next row automatically
    By lesoies in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-03-2012, 09:08 AM
  3. Run Macro Automatically from entering data into cell
    By yunesm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-07-2010, 01:53 PM
  4. Replies: 3
    Last Post: 11-06-2009, 04:50 PM
  5. Entering data automatically
    By luckyros in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-21-2009, 03:31 AM
  6. Automatically entering data in cells
    By dipdog in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-16-2006, 12:27 PM
  7. Replies: 3
    Last Post: 08-07-2006, 04:50 PM

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