Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
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
Taking Average ignoring #DIV/0! in the range... Astro Excel Worksheet Functions 1 April 16th 09 07:59 AM
taking an average of every 30 cells [email protected] Excel Discussion (Misc queries) 4 August 30th 07 04:27 PM
Average for different ranges William Excel Worksheet Functions 3 February 21st 07 05:23 PM
taking average of each set of all possible combinations Tom Mort Excel Programming 8 July 19th 04 09:59 PM
vba: Taking average of values in one column based on a corresponding value in another column eggsell Excel Programming 7 August 5th 03 01:12 PM


All times are GMT +1. The time now is 12:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"