Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default WorksheetFunction

Hi,

does someone have an idea why I can't run WorksheetFunction?? I have a code
as below, but I get errormessages for WorksheetFunctions..

Sub prov()
For Each c In MyRange
If c.Interior.ColorIndex = 3 Then
If myrange1 Is Nothing Then
Set myrange1 = c
Else
Set myrange1 = Union(myrange1, c)
End If
End If
redaverage = WorksheetFunction.Average(myrange1)
maxvalue = WorksheetFunction.max(myrange1)
medianvalue = WorksheetFunction.Median(myrange1)
Next
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default WorksheetFunction

Hi,

You haven't defined what MyRange is and your tring to evaluate the result
before the code has finished running. This uses the activesheet usedrange

Sub prov()
Dim MyRange As Range, MyRange1 As Range
Set MyRange = ActiveSheet.UsedRange
For Each c In MyRange
If c.Interior.ColorIndex = 3 Then
If MyRange1 Is Nothing Then
Set MyRange1 = c
Else
Set MyRange1 = Union(MyRange1, c)
End If
End If
Next
redaverage = WorksheetFunction.Average(MyRange1)
maxvalue = WorksheetFunction.Max(MyRange1)
medianvalue = WorksheetFunction.Median(MyRange1)

End Sub

Mike

"Ksenija" wrote:

Hi,

does someone have an idea why I can't run WorksheetFunction?? I have a code
as below, but I get errormessages for WorksheetFunctions..

Sub prov()
For Each c In MyRange
If c.Interior.ColorIndex = 3 Then
If myrange1 Is Nothing Then
Set myrange1 = c
Else
Set myrange1 = Union(myrange1, c)
End If
End If
redaverage = WorksheetFunction.Average(myrange1)
maxvalue = WorksheetFunction.max(myrange1)
medianvalue = WorksheetFunction.Median(myrange1)
Next
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default WorksheetFunction

Thanks:-)!!!!!!! evrything s working now!!!

"Mike H" skrev:

Hi,

You haven't defined what MyRange is and your tring to evaluate the result
before the code has finished running. This uses the activesheet usedrange

Sub prov()
Dim MyRange As Range, MyRange1 As Range
Set MyRange = ActiveSheet.UsedRange
For Each c In MyRange
If c.Interior.ColorIndex = 3 Then
If MyRange1 Is Nothing Then
Set MyRange1 = c
Else
Set MyRange1 = Union(MyRange1, c)
End If
End If
Next
redaverage = WorksheetFunction.Average(MyRange1)
maxvalue = WorksheetFunction.Max(MyRange1)
medianvalue = WorksheetFunction.Median(MyRange1)

End Sub

Mike

"Ksenija" wrote:

Hi,

does someone have an idea why I can't run WorksheetFunction?? I have a code
as below, but I get errormessages for WorksheetFunctions..

Sub prov()
For Each c In MyRange
If c.Interior.ColorIndex = 3 Then
If myrange1 Is Nothing Then
Set myrange1 = c
Else
Set myrange1 = Union(myrange1, c)
End If
End If
redaverage = WorksheetFunction.Average(myrange1)
maxvalue = WorksheetFunction.max(myrange1)
medianvalue = WorksheetFunction.Median(myrange1)
Next
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default WorksheetFunction

Glad I could help

"Ksenija" wrote:

Thanks:-)!!!!!!! evrything s working now!!!

"Mike H" skrev:

Hi,

You haven't defined what MyRange is and your tring to evaluate the result
before the code has finished running. This uses the activesheet usedrange

Sub prov()
Dim MyRange As Range, MyRange1 As Range
Set MyRange = ActiveSheet.UsedRange
For Each c In MyRange
If c.Interior.ColorIndex = 3 Then
If MyRange1 Is Nothing Then
Set MyRange1 = c
Else
Set MyRange1 = Union(MyRange1, c)
End If
End If
Next
redaverage = WorksheetFunction.Average(MyRange1)
maxvalue = WorksheetFunction.Max(MyRange1)
medianvalue = WorksheetFunction.Median(MyRange1)

End Sub

Mike

"Ksenija" wrote:

Hi,

does someone have an idea why I can't run WorksheetFunction?? I have a code
as below, but I get errormessages for WorksheetFunctions..

Sub prov()
For Each c In MyRange
If c.Interior.ColorIndex = 3 Then
If myrange1 Is Nothing Then
Set myrange1 = c
Else
Set myrange1 = Union(myrange1, c)
End If
End If
redaverage = WorksheetFunction.Average(myrange1)
maxvalue = WorksheetFunction.max(myrange1)
medianvalue = WorksheetFunction.Median(myrange1)
Next
End Sub

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
WorksheetFunction help Ayo Excel Discussion (Misc queries) 2 July 20th 08 10:48 PM
WorksheetFunction OR linglc Excel Programming 1 March 13th 07 07:46 AM
Worksheetfunction help Glen Mettler[_4_] Excel Programming 4 February 9th 05 11:41 PM
Max WorksheetFunction solo Excel Programming 4 February 23rd 04 10:17 PM
WorkSheetFunction.CountIf & WorkSheetFunction.SumIf with 2 conditions? Etien[_2_] Excel Programming 3 January 13th 04 04:07 PM


All times are GMT +1. The time now is 11:36 PM.

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"