+ Reply to Thread
Results 1 to 24 of 24

Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

  1. #1
    Forum Contributor
    Join Date
    06-09-2014
    Location
    Sweden
    Posts
    311

    Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

    Hi,

    Not sure is it possible or not but still hope for a way out.

    Please find the attachment .xlsm sheet -or- .Jpeg
    what i trying to achieve is in the Column M we have a value, When ever user enter Value in 'M14:M1048576'. Previous value enter should not be remove instead of that should add (+) new value next to its previous value.

    i.e:
    when user enter 1200 in M14 it should add like this =11000+1200 and appears total value in M14 in Formula Bar when cell is selected.

    It is possible when ever a user enter a value it appears with + and add the value next to the previous value

    sample.jpg

    sample Book1.xlsm

    looking forward for a solution

    Best

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Hi !

    Just using F2 - or double click - to edit the cell …

  3. #3
    Forum Contributor
    Join Date
    06-09-2014
    Location
    Sweden
    Posts
    311

    Re: Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

    Hi Marc,
    Thank you for your reply.
    There some confusion, As the the screenshot shown, I want to use VB formulas which auto add Plus sign in front of numbers present in M14 and add calculate the total value.
    To get the calculation result in column M14 without manually typing equal sign & Plus sign after each new value enter in 'M14:M1048576', is there any way to achieve it?

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    As editing a cell is at child level and can avoid drawback of using a VBA code …

    Anyway you can do it via VBA worksheet events :
    SelectionChange to save the cell formula,
    Change to add the content to the previous formula …

    But much ado about nothing !

  5. #5
    Forum Contributor
    Join Date
    06-09-2014
    Location
    Sweden
    Posts
    311

    Re: Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

    No exactly sure how to do that.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool

    To paste to the Sheet1 worksheet module :

    PHP Code: 
    Dim M$

    Private 
    Sub Worksheet_Change(ByVal Target As Range)
        If 
    Target.CountLarge And Target.Column 13 And Target.Row 13 Then
            
    If IsEmpty(TargetThen
                M 
    ""
            
    Else
                
    Application.EnableEvents False
                Target
    .Formula "+" Target.Value2
                Application
    .EnableEvents True
            End 
    If
        
    End If
    End Sub

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If 
    Target.CountLarge 1 Then If Target.Column 13 Then If Target.Row 13 Then _
        
    If Target.HasFormula Then M Target.Formula Else "=" Target.Value2
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 08-06-2019 at 12:01 PM. Reason: optimizing …

  7. #7
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,743

    Re: Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

    Please Login or Register  to view this content.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Exclamation

    KOKOSEK,

    if you select the cell M27 which has a value of 9000 then you enter 1000

    so the expected result is the formula =9000+1000 which is equal to 10000 but your code returns 12000 ‼

  9. #9
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,743

    Re: Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

    Yeah, you right. I've read i.e. part and missed line above.
    Last edited by KOKOSEK; 08-06-2019 at 12:19 PM.

  10. #10
    Registered User
    Join Date
    11-06-2012
    Location
    Texas
    MS-Off Ver
    O365
    Posts
    27

    Re: Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

    Edit: Ignore me.
    Last edited by Daishiknyte; 08-13-2019 at 10:17 AM.

  11. #11
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow


    'Undo' is very not necessary neither a second column as you can see in post #6 …

  12. #12
    Registered User
    Join Date
    11-06-2012
    Location
    Texas
    MS-Off Ver
    O365
    Posts
    27
    Ah. I hadn't considered using the selection change to track the previous value. That's going to change more than a few things in other projects.

    The second column was not necessary, but would make it easier to change the M column value if it needs to be reset.

  13. #13
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow


    I don't think it could be easier as more operations are necessary …

  14. #14
    Forum Contributor
    Join Date
    06-09-2014
    Location
    Sweden
    Posts
    311

    Re: Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

    Dear all contributors,
    Thank you for your kind reply and help on this. Sorry for reaching out this late as I was not able to follow the Posts due to some personal urgent work.

    I have tried to use all above codes but can't make it executable.

    It will be great help if you can put the code in the 'sample Book1.xlsm'' excel sheet which i was attach in P#1.


    Thank you and looking forward.

    Best,

  15. #15
    Forum Contributor
    Join Date
    06-09-2014
    Location
    Sweden
    Posts
    311

    Re: Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

    Hi,
    Is it possible to help me to put the code in the 'sample Book1.xlsm'' excel sheet which i was attach in P#1.
    I tired it but couldn't get it through.

    Thanks!

    Best,

  16. #16
    Forum Contributor
    Join Date
    06-09-2014
    Location
    Sweden
    Posts
    311

    Re: Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

    Hi,

    Any help for this thread

    Best,

  17. #17
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,004

    Re: Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

    Just copy Marc's code in post #6, open sheet1 then right click sheet1 tab > select View Code > paste the code.

  18. #18
    Forum Contributor
    Join Date
    06-09-2014
    Location
    Sweden
    Posts
    311

    Re: Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

    Hi Akuini,
    Thank you for guidance, i followed your given steps and code works appreciated.

    Best,
    Naveed Arif

  19. #19
    Forum Contributor
    Join Date
    06-09-2014
    Location
    Sweden
    Posts
    311

    Re: Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

    Quote Originally Posted by Marc L View Post
    To paste to the Sheet1 worksheet module :

    PHP Code: 
    Dim M$

    Private 
    Sub Worksheet_Change(ByVal Target As Range)
        If 
    Target.CountLarge And Target.Column 13 And Target.Row 13 Then
            
    If IsEmpty(TargetThen
                M 
    ""
            
    Else
                
    Application.EnableEvents False
                Target
    .Formula "+" Target.Value2
                Application
    .EnableEvents True
            End 
    If
        
    End If
    End Sub

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If 
    Target.CountLarge 1 Then If Target.Column 13 Then If Target.Row 13 Then _
        
    If Target.HasFormula Then M Target.Formula Else "=" Target.Value2
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Hi Marc,

    Your code works great as wanted thank you.
    But there is one issue in the code, i.e when you enter any new value -or- on the previous value for example new empty cell M29 I enter value of 100 then you enter 99 again (or any other value) it work fine but you remove 99 and enter any other value instead it doesn't allow you to remove any old value. You have to remove the whole value if there is a Type and enter again from scratch.

    Is it possible to make the code more flexible to add and remove any typo or previous value without entering from the very beginning.

    Thank you again for amazing code

    Best,

  20. #20
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    As I yet wrote the solution in post #2 & 4 : for common use a code is very not necessary as editing a cell is at child level !

    Now if you want to edit a cell, why asking for a not necessary code ?! So just use Excel like it is designed for !

    Edit : in fact it's not possible 'cause of your data validation, so the code stays as it is or just remove it and use Excel as usual …
    Last edited by Marc L; 08-16-2019 at 09:03 AM.

  21. #21
    Forum Contributor
    Join Date
    06-09-2014
    Location
    Sweden
    Posts
    311

    Re: Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

    Thank you, you right but people who mostly work on these sheet are not familiar with use Excel like it is designed for. So that why I'm here trying to make the data entry easier for them.

    Don't know Is it possible or not to make the code flexible fix the typos values entries without entering from the very beginning. Is there any solution of this

    Thanks,

    Best,

  22. #22
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Again, the solution is to trash the code if you want to edit a cell …

    The code can not be 'flexible' as Excel is not flexible, the code can't change the Excel entry behavior
    or you must delete the data validation and choose a special character (which can't be any operator sign like = / * - +)
    for adding the new value to the previous formula and amend the code accordingly.
    For example if a cell contains 11 000 and you wand to add 1 200 the entry should be &1200 but that's so superfluous …

  23. #23
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Or keeping the code as it is but adding a toggle button to activate / desactivate the events.

    For example, if you want to edit a cell, you must first think to click this button in order to desactivate the events,
    then use F2 to edit the cell then do not forget to click again the button in order to activate the events …

    Or instead of a toggle button use a button to edit the cell via an UserForm but it's much ado about nothing !

  24. #24
    Forum Contributor
    Join Date
    06-09-2014
    Location
    Sweden
    Posts
    311

    Re: Auto-evaluating: Auto Add after entering any value & display value in Formula Bar

    Thanks, Now i know.
    Appreciated your time and effort on this.

    I'll make this Thread as Solved.

    Thank you again

    Best,

+ 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. Auto Formula as soon as entering new data
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-18-2014, 07:48 AM
  2. auto entering date and time
    By LLOYD6664 in forum Excel General
    Replies: 2
    Last Post: 02-20-2014, 01:10 AM
  3. [SOLVED] Entering new Row in cell and it will Auto SUM
    By thursday140 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-03-2013, 08:42 AM
  4. Auto colors after entering a value
    By scortereal in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-06-2012, 12:51 PM
  5. Excel auto entering formulas
    By fishdude in forum Excel General
    Replies: 3
    Last Post: 06-03-2011, 02:09 AM
  6. Auto value colour display with =sum - small formula
    By Bartholemu in forum Excel - New Users/Basics
    Replies: 11
    Last Post: 08-14-2009, 06:53 AM
  7. [SOLVED] auto dating after entering the first date
    By Jomo Watts in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-05-2005, 11:06 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