#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 270
Default VBA Formulas

Hi
I have a situation where I would like to Sum, Average, etc entirely within
VBA
eg

Dim CountCol As Integer
Dim AvScore As Single

CountCol=Worksheets("Search").Evaluate("ROWS(H8:H3 00)-COUNTBLANK(H8:H300)")

'Would this be even close for the next bit? (Which I know is wrong)

AvScore=Worksheets("Search").Evaluate("AVERAGE(8, 11):(8+CountCol, 11)")

'The result from this is then allocated to a particular cell

Sheets("Sheet1").Range("A11").Value = AvScore

Thanks in advance
Sandy


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,624
Default VBA Formulas

One way:

Dim nCountCol As Long
Dim dAvScore As Double

With Worksheets("Search")
nCountCol = Application.WorksheetFunction.CountIf( _
.Range("H8:H300"), "<" & vbNullString)
dAvScore = Application.WorksheetFunction.Average( _
.Range("K8").Resize(nCountCol, 1))
End With
Sheets("Sheet1").Range("A11").Value = dAvScore


In article ,
"Sandy" wrote:

Hi
I have a situation where I would like to Sum, Average, etc entirely within
VBA
eg

Dim CountCol As Integer
Dim AvScore As Single

CountCol=Worksheets("Search").Evaluate("ROWS(H8:H3 00)-COUNTBLANK(H8:H300)"
)

'Would this be even close for the next bit? (Which I know is wrong)

AvScore=Worksheets("Search").Evaluate("AVERAGE(8, 11):(8+CountCol, 11)")

'The result from this is then allocated to a particular cell

Sheets("Sheet1").Range("A11").Value = AvScore

Thanks in advance
Sandy

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
CELLS NOT CALC FORMULAS - VALUES STAY SME FORMULAS CORRECT?? HELP Sherberg Excel Worksheet Functions 4 September 11th 07 01:34 AM
automatically copy formulas down columns or copy formulas all the HowlingBlue Excel Worksheet Functions 1 March 16th 07 11:11 PM
Formulas not evaluated, Formulas treated as strings Bob Sullentrup Excel Discussion (Misc queries) 0 November 27th 06 08:01 PM
formulas las New Users to Excel 2 April 20th 06 04:30 PM
formulas for changing formulas? creativeops Excel Discussion (Misc queries) 4 January 26th 06 03:07 AM


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