Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Correct VBA syntax for cell function formula


The following formula works great in a worksheet cell at counting every
5th row (5 rows total) that contains data:

=SUMPRODUCT(--(A1:A100<""),--(MOD(ROW(A1:A100),5)=1))

However, I can't get the correct syntax for it to work in VBA code.
Can someone help? Thanks a million. mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=467694

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Correct VBA syntax for cell function formula

The only way that I know to use formulas like that in VBA is using the
Evaluate() method. What part of that are you trying to use from VBA ?

--
Regards,

Juan Pablo González
Excel MVP

"mikeburg" wrote in
message ...

The following formula works great in a worksheet cell at counting every
5th row (5 rows total) that contains data:

=SUMPRODUCT(--(A1:A100<""),--(MOD(ROW(A1:A100),5)=1))

However, I can't get the correct syntax for it to work in VBA code.
Can someone help? Thanks a million. mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile:
http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=467694



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Correct VBA syntax for cell function formula

mikeburg,

This will sum every 5th row in a column. It

Sub Sum_Column()
Dim i As Integer
Dim x As Integer
Dim rng As Range

For i = 1 To 20 ' 5*20 = 100 cells

x = (i - 1) * 5

With Worksheets("Data") 'worksheet name
Set rng = .Range(.Cells(1 + x, 1), .Cells(5 + x, 1)) ' how to define range
to sum
..Cells(5 * i, 3) = Application.WorksheetFunction.Sum(rng) 'sum the range and
place it in cell (c5, c10, etc)
End With

Next i

End Sub


"mikeburg" wrote in
message ...

The following formula works great in a worksheet cell at counting every
5th row (5 rows total) that contains data:

=SUMPRODUCT(--(A1:A100<""),--(MOD(ROW(A1:A100),5)=1))

However, I can't get the correct syntax for it to work in VBA code.
Can someone help? Thanks a million. mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile:
http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=467694



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
Correct Syntax for Changing Color of Cell Based on Value W Excel Discussion (Misc queries) 3 December 6th 08 10:39 PM
Correct Syntax TeeSee Excel Discussion (Misc queries) 6 February 28th 08 01:36 AM
Correct VBA syntax Ken G. Excel Discussion (Misc queries) 3 December 7th 05 12:35 AM
If...and... - can never get the syntax correct! Darin Kramer Excel Programming 12 March 24th 05 04:18 PM
Can't get this syntax correct, please help. Sharlene England Excel Programming 4 December 1st 03 05:41 PM


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