Save to other worksheet

noelmus

Board Regular
Joined
Dec 30, 2018
Messages
105
Hi,
In worksheet "Total" I have cell G24=E22+H22. Cell G24 changes its value more than once after I change E22 or H22. I need that if cell J12 in worksheet "Total" is 2, the value of G24 will be recorded in worksheet "Grand Total" in cell A2 after I save worksheet "Total".
Another need is that when Cell G24 changes and I save again, it will be recorded in worksheet "Grand Total" in cell A3. So every time I save, it records Cell G24 in the next row.


Thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Put the following code in the Thisworkbook events

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    If Sheets("Total").Range("J12").Value = 2 Then
        Set ht = Sheets("Grand Total")
        u = ht.Range("A" & Rows.Count).End(xlUp).Row + 1
        ht.Range("A" & u).Value = Sheets("Total").Range("G24").Value
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,348
Members
452,638
Latest member
Oluwabukunmi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top