Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taking an average of ranges
I am selecting data for various compounds and would like to then take
that data and average it and then put it into a cell. The problem I am having is that I don't quite know how to average this data. My code is below and probably outlines it better. Basically I can have multiple compounds and would like to average the data from each compound individually and then input that average into a cell (which would correspond to the specific compound. Worksheets("Sheet1").Activate Dim TempGPCR1 As Range Dim GPCR1data() As String Dim i As Long For i = 1 To numCpd1 Worksheets("Sheet1").Activate Set TempGPCR1 = Application.InputBox("Please Select Data for Compound " & i, Type:=8) 'Worksheets("Sheet3").Activate avegpcr = WorksheetFunction.Average(TempGPCR1) ["B"&i+1].Value = avegpcr Next i Is it just the way my code is written or is this not easily done? Another question involves making a calculation and stopping when it reaches a blank cell. I just want a simple division but the numbers I will be dividing by one another are on a different sheet than where I would like the results. Any thoughts on how I can accomplish this? TIA Stephen |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Taking an average of ranges
["B"&i+1].Value = avegpcr
should be Range("B"&i+1).Value = avegpcr -- Regards, Tom Ogilvy wrote in message ups.com... I am selecting data for various compounds and would like to then take that data and average it and then put it into a cell. The problem I am having is that I don't quite know how to average this data. My code is below and probably outlines it better. Basically I can have multiple compounds and would like to average the data from each compound individually and then input that average into a cell (which would correspond to the specific compound. Worksheets("Sheet1").Activate Dim TempGPCR1 As Range Dim GPCR1data() As String Dim i As Long For i = 1 To numCpd1 Worksheets("Sheet1").Activate Set TempGPCR1 = Application.InputBox("Please Select Data for Compound " & i, Type:=8) 'Worksheets("Sheet3").Activate avegpcr = WorksheetFunction.Average(TempGPCR1) ["B"&i+1].Value = avegpcr Next i Is it just the way my code is written or is this not easily done? Another question involves making a calculation and stopping when it reaches a blank cell. I just want a simple division but the numbers I will be dividing by one another are on a different sheet than where I would like the results. Any thoughts on how I can accomplish this? TIA Stephen |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Taking Average ignoring #DIV/0! in the range... | Excel Worksheet Functions | |||
taking an average of every 30 cells | Excel Discussion (Misc queries) | |||
Average for different ranges | Excel Worksheet Functions | |||
taking average of each set of all possible combinations | Excel Programming | |||
vba: Taking average of values in one column based on a corresponding value in another column | Excel Programming |