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 |
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 |
All times are GMT +1. The time now is 11:24 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com