+ Reply to Thread
Results 1 to 4 of 4

Autosum new entries

  1. #1
    Registered User
    Join Date
    02-05-2019
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2016
    Posts
    3

    Autosum new entries

    Hi,

    I'm fairly new to the whole VBA world.

    I have made a simpel button that adds a new row below a certain cell, adds a text to the new B# cell and a number to the new C# cell.

    I also used the =SUM(INDIRECT("C18:C"&ROW()-1)) below to sum up the new numbers. So far so good.

    Now I need another button and rows that does the same, but below the first sum, and thats a problem for me.

    The problem is that I did the same thing further down the sheet, again using =SUM(INDIRECT("C26:C"&ROW()-1)). But if I pushed the first button say three times, three new rows are put into the sheet and the second autosum isn't working anymore since its no longer "C26" but now "C29" thats the start of the new sum.

    If you look at the picture, what happens is when I press my button it inserts a new row and adds 10,000.00 after row 18, and the autosum keeps adding up perfectly - but every time I press the button the Liabilities is moved 1 row down and the formula isnt working.

    Any tips?
    Attached Images Attached Images

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Autosum new entries

    Hi and welcome to the forum.
    Please upload a workbook or a representative cut down copy, anonymised if necessary. It is always easier to advise if we can see your request in its context.

    Show a before and after situation with manually calculated results, explaining which information is data and which is results, and if it's not blindingly obvious how you have arrived at your results some explanatory notes as well.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    02-05-2019
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2016
    Posts
    3

    Re: Autosum new entries

    Hi - just uploaded the workbook.

    Don't mind the button "Indtægter" and "Rådighedsbeløb" as well as cell A1:C16, they are not part of the problem.

    The code is on "Knap 7" button and is

    Sub Knap7_Klik()

    ActiveSheet.Cells(18, 1).Select
    Rows(19).Insert Shift:=xlShiftDown
    ActiveCell.Offset(1, 0).Value = "ejendom"
    ActiveCell.Offset(1, 1).Value = "tDKK"
    ActiveCell.Offset(1, 2).Value = CDbl("10000")
    ActiveCell.Offset(1, 2).NumberFormat = "#,###"

    End Sub

    The first autosum is - without data in cell C20 and works fine when button "Knap 7" is pushed - the problem is the autosum under Liabilties (without new rows cell C25).
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    02-05-2019
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2016
    Posts
    3

    Re: Autosum new entries

    Quote Originally Posted by CazorDK View Post
    Hi - just uploaded the workbook.

    Don't mind the button "Indtægter" and "Rådighedsbeløb" as well as cell A1:C16, they are not part of the problem.

    The code is on "Knap 7" button and is

    Sub Knap7_Klik()

    ActiveSheet.Cells(18, 1).Select
    Rows(19).Insert Shift:=xlShiftDown
    ActiveCell.Offset(1, 0).Value = "ejendom"
    ActiveCell.Offset(1, 1).Value = "tDKK"
    ActiveCell.Offset(1, 2).Value = CDbl("10000")
    ActiveCell.Offset(1, 2).NumberFormat = "#,###"

    End Sub

    The first autosum is - without data in cell C20 and works fine when button "Knap 7" is pushed - the problem is the autosum under Liabilties (without new rows cell C25).
    The button "knap 7" should just put a new row below row 18 with the phrase "ejendom" in A column, "tDKK" in B column and 10,000 in C column, and the autosum under Assets should just auto sum.

    I want to build a button the same under Liabilities, but I cant figure out how to autosum, as it moves the rows down, so the autoformula wont work.

+ 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. Replies: 1
    Last Post: 11-27-2017, 08:50 PM
  2. [SOLVED] restrict a search to either text entries or date entries when loading dynamic userform
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2017, 06:06 AM
  3. [SOLVED] Move Non-Zero row entries up to occupy Zero row entries. Rows deletion not allowed
    By chancw in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-08-2013, 03:57 AM
  4. Replies: 1
    Last Post: 02-01-2013, 03:38 PM
  5. [SOLVED] Read entries-locate entries and print entries
    By akotronis in forum Excel General
    Replies: 4
    Last Post: 05-01-2012, 03:05 PM
  6. Removing repeat entries in a long column of data entries
    By kaizhong1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-15-2010, 01:31 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