LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default select range in column, calculate on range plus 3 columns, output inrange plus 7 columns


I see the problem now.
If you have 4 cells containing 2,5,nvt,blank, what do you want the
average to be?
Chip's gives 3.5, both my snippets give 2.333. This is because my
formula treats blank cells as a zero. Probably not what you want.

Do you want to exclude both strings and empty cells from the averaging
altogether?

Using Evaluate in Chip's code will still cause an error so I suggest
using an adaptation of his code:


Set R = Range("FirstCell")
R.CurrentRegion.Sort R, xlAscending
Set R2 = R
Do Until R.Value = vbNullString
If StrComp(R.Text, R(2, 1).Text, vbTextCompare) = 0 Then
N = N + 1
Else
xxx = Empty
On Error Resume Next
xxx = Application.WorksheetFunction.Average(R2(1, 3).Resize(N + 1,
1))
On Error GoTo 0
R2(1, 7).Resize(N + 1, 1) = "Average of '" & R.Text &
IIf(IsEmpty(xxx), "' = Oops!", "' = " & xxx)
N = 0
Set R2 = R(2, 1)
End If
Set R = R(2, 1)
Loop
End Sub


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: 558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=176334

Microsoft Office Help



 
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
Select different columns within a range Kiran Charts and Charting in Excel 0 March 8th 10 01:22 PM
Select range of rows/Columns? Cam Excel Programming 3 August 28th 07 09:01 PM
Copy range from multiple .xls files - output to separate columns per .xls file qwerty01 Excel Programming 2 June 13th 07 08:29 PM
Modfiy row of VB to select range of columns Darin Kramer Excel Programming 2 August 22nd 06 10:53 PM
VBA Range Issue : Cannot programatically select more than 42 columns Learner[_3_] Excel Programming 4 January 31st 05 09:55 PM


All times are GMT +1. The time now is 05:06 PM.

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

About Us

"It's about Microsoft Excel"