wilkisa
Well-known Member
- Joined
- Apr 7, 2002
- Messages
- 657
- Office Version
- 365
- 2016
- 2013
- Platform
- Windows
I have the following code:Sub Sample()
'Add new sheet
Sheets.Add
' Move sheet to end
ActiveSheet.Move After:=Sheets(Worksheets.Count)
ActiveSheet.[a7] = "Previous Value:"
ActiveSheet.[d7] = "Current Values:"
ActiveSheet.[d9] = "Total Value:"
ActiveSheet.[b7] = Sheets(Worksheets.Count - 1).[e7]
ActiveSheet.[e7] = "=SUM(R[-6]C:R[-1]C)"
ActiveSheet.[e9] = "=SUM(R[-2]C[-3],R[-2]C)"
ActiveSheet.[B7,E1:E9].NumberFormat = "0.00"
ActiveSheet.[A:E].ColumnWidth = 15
ActiveSheet.Range("E1").Select
End Sub
What I need to have changed is the reference to the ActiveSheet.[b7]. Instead of it being a hard number, I need it to be linked to the previous sheet so that it will update if a change is made in the previous sheet. Can someone help with this?
'Add new sheet
Sheets.Add
' Move sheet to end
ActiveSheet.Move After:=Sheets(Worksheets.Count)
ActiveSheet.[a7] = "Previous Value:"
ActiveSheet.[d7] = "Current Values:"
ActiveSheet.[d9] = "Total Value:"
ActiveSheet.[b7] = Sheets(Worksheets.Count - 1).[e7]
ActiveSheet.[e7] = "=SUM(R[-6]C:R[-1]C)"
ActiveSheet.[e9] = "=SUM(R[-2]C[-3],R[-2]C)"
ActiveSheet.[B7,E1:E9].NumberFormat = "0.00"
ActiveSheet.[A:E].ColumnWidth = 15
ActiveSheet.Range("E1").Select
End Sub
What I need to have changed is the reference to the ActiveSheet.[b7]. Instead of it being a hard number, I need it to be linked to the previous sheet so that it will update if a change is made in the previous sheet. Can someone help with this?