The code looks at column B of the ToWks to find the last used row. Then it puts
the formula you have in A1 of the FromWks.
Try it manually.
Select A1:A99
type =B1
hit ctrl-enter
That's what the code is doing, too.
There's an event called worbook_beforeclose that is called right before you
close the workbook. There's another event that's called workbook_beforesave.
Since you can save via File|Save, this can run more often.
Chip Pearson has some nice notes about workbook/worksheet events at:
http://www.cpearson.com/excel/events.htm
If you decide to put it in the workbook_beforeclose, you could add a line like:
me.save
to the code
This is placed under the ThisWorkbook module (not under a worksheet, not in a
general module):
Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim FromWks As Worksheet
Dim ToWks As Worksheet
Set FromWks = Worksheets("sheet1")
Set ToWks = Worksheets("sheet2")
With ToWks
.Range("a1:a" & .Cells(.Rows.Count, "B").End(xlUp).Row).FormulaR1C1 _
= FromWks.Range("a1").FormulaR1C1
End With
Me.Save
End Sub