#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default 2 VB Questions

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
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 342
Default 2 VB Questions

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
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 342
Default 2 VB Questions

I forgot it was a different sheet. Try this:

Sub testit()

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

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
View Questions and Answer to questions I created Roibn Taylor Excel Discussion (Misc queries) 4 July 24th 08 12:05 AM
2 Questions Rich Stanek Excel Worksheet Functions 1 June 7th 07 09:43 AM
2 questions Sally Sibthorpe Charts and Charting in Excel 9 July 26th 06 10:15 PM
Max / IF questions G Excel Discussion (Misc queries) 1 October 12th 05 03:27 AM
Two Questions mike New Users to Excel 2 June 24th 05 12:35 AM


All times are GMT +1. The time now is 07:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"