Forum Discussion
Formula
- Sep 21, 2019
Based on your description, assuming you have two sheets called "Tracking" and "Invoice" and if you want to copy the cell A13 on Invoice Sheet if changed to the first empty cell after the last row with data in column A on Tracking Sheet, place the following code on the Invoice Sheet Module.
To do so, right click on Invoice Sheet Tab --> View Code and paste the code given below into the opened code window and save your workbook as Macro-Enabled Workbook.
If name of your tracking sheet is not "Tracking", change the name of tracking sheet it in the code.
Private Sub Worksheet_Change(ByVal Target As Range) If Target.CountLarge > 1 Then Exit Sub Dim wsDest As Worksheet Set wsDest = Worksheets("Tracking") 'Assuming Tracking is the name of the Tracking Sheet, change it as required If Target.Address(0, 0) = "A13" Then If Target <> "" Then Target.Copy wsDest.Range("A" & Rows.Count).End(3)(2) End If End If End SubLet me know if this is what you were trying to achieve.
Hi
To run the code whenever A13 changes in the Invoice worksheet, then
You need to attach the code to cell A13 Change event:
To do that,
Right click the worksheet Tab (Invoice) >> select view code
In the VB Editor, you have 2 drop lists, from the left one select "Worksheet" from the Right one select "Change"
Then write the code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("A13").Address Then
Call Evaluate
End If
End Sub
If you want to check if a cell is empty then proceed to the cell below without overwriting, that requires modifying the Evaluate code and let it loop before copying.