Excel Excel - average vba


Joined
May 6, 2011
Messages
13
Reaction score
0
Hi, i want to find the average of a range of cells (D11:D20) and insert it into D21 when the active cell row is 21

this should be pretty easy for the more technical people so a quick response would be appreciated.

it should start off like this ;

if activecell.row = 21 then....

Cheers in advance
 
Ad

Advertisements

Joined
May 31, 2011
Messages
32
Reaction score
0
Hi,

Will your range be always be D11:D20?

if it's the case : this should help you :

Range("D21").Value = Application.WorksheetFunction.Sum(Range("D11:D20")) / Range("D11:D20").Count

Sifou
 
Joined
Sep 3, 2008
Messages
164
Reaction score
5
cuddihy2k7,

You may need to compare the value in your active cell to compare it to the value '21'
psudocode:
declare a variable to capture the value of the active cell (variable name = activecell.value)
use the worksheet change event
on change if the active cell value = '21' then execute the line of code from Sifou
release variable values
Or you may ask the moderator if it is OK to send a sample workbook via private message and I could provide the macro.

Stoneboysteve
 
Ad

Advertisements

Joined
May 6, 2011
Messages
13
Reaction score
0
thanks lads, this helped a lot, I just needed this bit of code and everything else seems to be working fine, this is just what I need in the spreadsheet that should be soon sent out to multiple users
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top