Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default how to sum a complete colum on another sheet in VBA

Hi,
I'am a novice on VBA programming....
On worksheet1 i have cell A1 which must be filled with the sum of colum P on
worksheet2 (without going back and forth between the two sheets)

in excel i would use the formula sum(P:P) on sheet 2 in eg cel A1 en step 2
would be to link cel A1 in sheet1 tot A1 in sheet2....

Does anyone have a clue how to do that in VBA ?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default how to sum a complete colum on another sheet in VBA

Hi Jean-Pierre,

Try:

Sub TestIt()
Dim MySum As Double

MySum = Application.Sum(Sheets("Sheet2").Columns("P:P"))
MsgBox MySum

End Sub



---
Regards,
Norman



"Jean-Pierre D via OfficeKB.com" wrote in message
...
Hi,
I'am a novice on VBA programming....
On worksheet1 i have cell A1 which must be filled with the sum of colum P
on
worksheet2 (without going back and forth between the two sheets)

in excel i would use the formula sum(P:P) on sheet 2 in eg cel A1 en step
2
would be to link cel A1 in sheet1 tot A1 in sheet2....

Does anyone have a clue how to do that in VBA ?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default how to sum a complete colum on another sheet in VBA

Hi Jean Pierre,

My suggestion returns a static value, so go with Topper's dynamic formula
approach.

---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Jean-Pierre,

Try:

Sub TestIt()
Dim MySum As Double

MySum = Application.Sum(Sheets("Sheet2").Columns("P:P"))
MsgBox MySum

End Sub



---
Regards,
Norman



"Jean-Pierre D via OfficeKB.com" wrote in message
...
Hi,
I'am a novice on VBA programming....
On worksheet1 i have cell A1 which must be filled with the sum of colum P
on
worksheet2 (without going back and forth between the two sheets)

in excel i would use the formula sum(P:P) on sheet 2 in eg cel A1 en step
2
would be to link cel A1 in sheet1 tot A1 in sheet2....

Does anyone have a clue how to do that in VBA ?





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default how to sum a complete colum on another sheet in VBA

Worksheets("Sheet1").Range("a1") = "=SUM(Sheet2!P:P)"

"Jean-Pierre D via OfficeKB.com" wrote:

Hi,
I'am a novice on VBA programming....
On worksheet1 i have cell A1 which must be filled with the sum of colum P on
worksheet2 (without going back and forth between the two sheets)

in excel i would use the formula sum(P:P) on sheet 2 in eg cel A1 en step 2
would be to link cel A1 in sheet1 tot A1 in sheet2....

Does anyone have a clue how to do that in VBA ?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default how to sum a complete colum on another sheet in VBA

Hi Toppers,

Thanks for the formula but the result is tha in cell "A1" the formula is put
and that is not what i wanted. I would like to have the result of the formula
eg the sum of the column in cell "A1"
Can you help me please?
Thanks,
Jean-Pierre (novice)

Toppers wrote:
Worksheets("Sheet1").Range("a1") = "=SUM(Sheet2!P:P)"

Hi,
I'am a novice on VBA programming....

[quoted text clipped - 5 lines]

Does anyone have a clue how to do that in VBA ?



--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200508/1


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default how to sum a complete colum on another sheet in VBA

The result in A! is the value as the formula is automatically evaluated.

Otherwise, use Norman's code and add:

Worksheets("Sheet1").Range("a1")=mysum

HTH

"Jean-Pierre D via OfficeKB.com" wrote:

Hi Toppers,

Thanks for the formula but the result is tha in cell "A1" the formula is put
and that is not what i wanted. I would like to have the result of the formula
eg the sum of the column in cell "A1"
Can you help me please?
Thanks,
Jean-Pierre (novice)

Toppers wrote:
Worksheets("Sheet1").Range("a1") = "=SUM(Sheet2!P:P)"

Hi,
I'am a novice on VBA programming....

[quoted text clipped - 5 lines]

Does anyone have a clue how to do that in VBA ?



--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200508/1

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
Using one sheet to complete information in another sheet Anne Excel Worksheet Functions 3 February 23rd 09 09:31 PM
Link Complete Sheet VIVEKMANE Excel Worksheet Functions 6 October 29th 07 07:16 AM
how do i sort a complete work sheet in excel Jerry Excel Discussion (Misc queries) 2 April 27th 06 01:51 AM
How to find a row in a sheet and compare the complete row /w origi Jazz - Netherlands Excel Worksheet Functions 0 March 29th 06 10:22 AM
have macros complete and enter passwords for sheet protection. nick-ipswich Excel Programming 1 March 13th 05 04:52 AM


All times are GMT +1. The time now is 12:28 PM.

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"