Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default SUM() cells by variables

Here's the code that it doesn't like:

myWorkCell(myCount, 17) = SUM(myWorkCell(2, 13):myWorkCell(myCount, 13))

Let's say myCount is 5, I'm expecting the cell 5 rows down and 17 to the
right to receive the value of all cells from 2 rows down and 13 to the right
to 5 rows down and 13 to the right .. in this case if myWorkCell.Row is 11,
it would present me with:

S(16) = SUM(N(12):N(16))

...at least that's what I thought I'd get. But, of course, I didn't <g!

Help, please.
--
Dave
Temping with Staffmark
in Rock Hill, SC
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default SUM() cells by variables

Hi Dave,

Perhaps, try something like:

'=============
Public Sub Tester()
Dim myWorkCell As Range
Dim myCount As Long

Set myWorkCell = Range("A1")
myCount = 5

myWorkCell(myCount, 17) = _
Application.Sum(myWorkCell(2, 13).Resize(myCount))
End Sub
'<<=============


---
Regards,
Norman




"Dave Birley" wrote in message
...
Here's the code that it doesn't like:

myWorkCell(myCount, 17) = SUM(myWorkCell(2, 13):myWorkCell(myCount, 13))

Let's say myCount is 5, I'm expecting the cell 5 rows down and 17 to the
right to receive the value of all cells from 2 rows down and 13 to the
right
to 5 rows down and 13 to the right .. in this case if myWorkCell.Row is
11,
it would present me with:

S(16) = SUM(N(12):N(16))

..at least that's what I thought I'd get. But, of course, I didn't <g!

Help, please.
--
Dave
Temping with Staffmark
in Rock Hill, SC



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default SUM() cells by variables

Hi Dave,

Alternatively, depending on your intended target cell, try:

'=============
Public Sub Tester()
Dim myWorkCell As Range
Dim myCount As Long

Set myWorkCell = Range("A1")
myCount = 5

myWorkCell.Offset(myCount, 17) = _
Application.Sum(myWorkCell(2, 13).Resize(myCount))
End Sub
'<<=============


---
Regards,
Norman


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default SUM() cells by variables

Kewl!! I'll give that dude a shot too -- the first one worked with
qualifications -- except the qualifications had nothing to do with YOUR
contribution <g!
--
Dave
Temping with Staffmark
in Rock Hill, SC


"Norman Jones" wrote:

Hi Dave,

Alternatively, depending on your intended target cell, try:

'=============
Public Sub Tester()
Dim myWorkCell As Range
Dim myCount As Long

Set myWorkCell = Range("A1")
myCount = 5

myWorkCell.Offset(myCount, 17) = _
Application.Sum(myWorkCell(2, 13).Resize(myCount))
End Sub
'<<=============


---
Regards,
Norman



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default SUM() cells by variables

Yup, fer sure -- Version 2 was slicker 'n a pig in poop. Did the job perfectly.

Can't thank you enough! (Something about "job security" <g).
--
Dave
Temping with Staffmark
in Rock Hill, SC


"Norman Jones" wrote:

Hi Dave,

Alternatively, depending on your intended target cell, try:

'=============
Public Sub Tester()
Dim myWorkCell As Range
Dim myCount As Long

Set myWorkCell = Range("A1")
myCount = 5

myWorkCell.Offset(myCount, 17) = _
Application.Sum(myWorkCell(2, 13).Resize(myCount))
End Sub
'<<=============


---
Regards,
Norman





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default SUM() cells by variables

Just what I needed!!!! Thanks.
--
Dave
Temping with Staffmark
in Rock Hill, SC


"Norman Jones" wrote:

Hi Dave,

Perhaps, try something like:

'=============
Public Sub Tester()
Dim myWorkCell As Range
Dim myCount As Long

Set myWorkCell = Range("A1")
myCount = 5

myWorkCell(myCount, 17) = _
Application.Sum(myWorkCell(2, 13).Resize(myCount))
End Sub
'<<=============


---
Regards,
Norman




"Dave Birley" wrote in message
...
Here's the code that it doesn't like:

myWorkCell(myCount, 17) = SUM(myWorkCell(2, 13):myWorkCell(myCount, 13))

Let's say myCount is 5, I'm expecting the cell 5 rows down and 17 to the
right to receive the value of all cells from 2 rows down and 13 to the
right
to 5 rows down and 13 to the right .. in this case if myWorkCell.Row is
11,
it would present me with:

S(16) = SUM(N(12):N(16))

..at least that's what I thought I'd get. But, of course, I didn't <g!

Help, please.
--
Dave
Temping with Staffmark
in Rock Hill, SC




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
Fill cells automatically from 2 variables Ned Harrison Excel Worksheet Functions 8 September 1st 09 10:47 AM
Split values in cells to variables [email protected] Excel Discussion (Misc queries) 4 January 15th 08 02:41 AM
How to one cells variables as a serie to a column noyau New Users to Excel 6 December 22nd 06 10:58 AM
summing cells with variables jeff Excel Discussion (Misc queries) 5 March 3rd 05 07:25 PM
writing cells with variables from vba josh ashcraft Excel Programming 0 July 17th 03 03:32 PM


All times are GMT +1. The time now is 02:20 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"