+ Reply to Thread
Results 1 to 3 of 3

Macro for formula result loging/recording

Hybrid View

  1. #1
    Registered User
    Join Date
    03-12-2015
    Location
    Lithuania
    MS-Off Ver
    2010
    Posts
    1

    Macro for formula result loging/recording

    Dear all,

    I need a little bit of help. I'm trying to find/make a VBA code which could log results from the formula in a table. After any variable change the formula results should be recorded in to the table and it should keep a last 10 records. After the table is filled up, the very last result should be deleted and the 10 recent results should be present. I have attached a sample xls file for beter understanding.Result loging.xlsx

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Macro for formula result loging/recording

    Hi,
    Welcome to the forum.

    Right Click on Sheet1 Tab --> View Code and place the code given below in the opened code window --> Save your workbook as Excel Macro-Enabled Workbook.
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim r As Long
    If Target.Count > 1 Then Exit Sub
    If Target.Address(0, 0) = "F2" Or Target.Address(0, 0) = "H2" Then
            If Range("B17").Value = "" Then
                    r = 17
                    Cells(r, "B") = Cells(3, "B")
                    Cells(r, "C") = Cells(r, "C")
            ElseIf Range("B17").End(xlUp).Row < 8 Then
                    r = 16
                    Cells(r, "B") = Cells(3, "B")
                    Cells(r, "C") = Cells(r, "C")
            ElseIf Range("B17").End(xlUp).Row > 8 Then
                    r = Range("B17").End(xlUp).Row - 1
                    Cells(r, "B") = Cells(3, "B")
                    Cells(r, "C") = Cells(3, "C")
            ElseIf Range("B17").End(xlUp).Row = 8 Then
                    r = 8
                    Range("B8:C16").Copy
                    Range("B9").PasteSpecial xlPasteValues
                    Cells(r, "B") = Cells(3, "B")
                    Cells(r, "C") = Cells(r, "C")
            End If
    End If
    End Sub
    This is a Worksheet_Change Event Code, so once you change the value in H2, that will change the values returned by the Formula1 and Formula2 and hence will trigger the code to place the formula results in the desired row in the table.

    For detail see the attached.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Macro for formula result loging/recording

    Glad that it is working as per your requirement. Thanks for the feedback.


    If that takes care of your original question, please mark your thread as Solved by selecting Thread Tools (just above your first post) --> Mark thread as solved.

+ 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. Session Recording (Login info recording)
    By cvishu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2014, 04:10 PM
  2. Recording more than one result using the match function
    By Chris Bucky in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-04-2014, 08:11 AM
  3. [SOLVED] Macro doesnt paste value the result of the formula but the formula itself..
    By extremis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2013, 11:06 AM
  4. Replies: 1
    Last Post: 01-27-2013, 11:05 AM
  5. Replies: 1
    Last Post: 01-10-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