2 VB Questions

  • Thread starter Thread starter JRD-CFW
  • Start date Start date
J

JRD-CFW

1) If I'm writing a worksheet_change for sheet1, how do i get it to reference
sheet2? That is, I want Sum(Sheet2!A2:A10)?

2) If I have A1=Sum(Range("A2:A10")) written into VB, how do I make it
update automatically when I change the value in, say, A3?

Thanks.

JRD-CFW
 
If you put this formula:

=SUM(A2:A10)

in cell A1 it will automatically update any time there is a change to the
worksheet.


However, if you need to do it in code, try this:

Sub testit()

ActiveSheet.Range("A1").Value = WorksheetFunction _
..Sum(Range("A2:A10"))

End Sub


I hope that helps.

Tom
 
I forgot it was a different sheet. Try this:

Sub testit()

ActiveSheet.Range("A1").Value = WorksheetFunction _
..Sum(Sheets("Sheet2").Range("A2:A10"))

End Sub
 
Back
Top