Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Calculations on Cell Values in VBA
I'd like to perform some calculations on cell values in VBA, for exampl
: price temperature 10 100 20 150 30 200 What I'd like to do is sum the prices and average the temperatures, an enter the results in a given cell, using variables as cell reference (I don't know the absolute row reference for the data columns). Here's the line of code I have so far : Cells(Count, 1) = WorksheetFunction.Sum(Range("a" TopRowOfCurrentTable & ":a" & (Count - 1))) Where 'Count' is a loop variable that identifies the row below the las row in a given table and 'TopRowOfCurrentTable' identifies the top row When I run this code I get Error 1004 Method 'Range' of object '_Global' failed Any idea why it's not working ? I know I could build a loop to simpl add all the values using a variable and then enter it into the cell but I thought that using a worksheet function like this would be mor efficient. Thanks, Blewy -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
getting excel to take '<' values into account in calculations | Excel Discussion (Misc queries) | |||
Managing the Presentation of Zero values in Calculations in Charts | Charts and Charting in Excel | |||
Calculations based on adjacent cell values | Excel Discussion (Misc queries) | |||
Calculations from date and time values | Excel Worksheet Functions | |||
How do I do count calculations ignoring duplicate values | Excel Discussion (Misc queries) |