Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using a range with isnumber property


i would like to know if i there is a way i could use either IsBlank o
IsNumber in this.
I have a new range every iteration, and i just want the program to ski
the range if there is no numbers entered in it. Otherwise, the progra
(upon execution) gives an error for the StDev function because there i
nothing in the range to calculate.

here is the code so far... thank you for helping!

Sub calc_mean()
Dim J As Integer
Dim K As Integer
Dim rng As Range

' Calculation of standard deviation and mean.

For J = 4 To 192
For K = 0 To 7
Set rng = Range("D" & J + K, "O" & J + K)
If Application.WorksheetFunction.IsNumber(rng) = True Then

Cells(J + K, "R") = Application.WorksheetFunction.Average(rng)
Cells(J + K, "S") = Application.WorksheetFunction.StDev(rng)
End If

Next K
J = J + 10
Next J
End Su

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default using a range with isnumber property

For J = 4 To 192
For K = 0 To 7
Set rng = Range("D" & J + K, "O" & J + K)
If Application.WorksheetFunction.Count(rng) 0 Then

Cells(J + K, "R") = Application.WorksheetFunction.Average(rng)
Cells(J + K, "S") = Application.WorksheetFunction.StDev(rng)
End If

Next K

Count will tell you how many numbers are in the range.

--
Regards,
Tom Ogilvy


"chick-racer" wrote in message
...

i would like to know if i there is a way i could use either IsBlank or
IsNumber in this.
I have a new range every iteration, and i just want the program to skip
the range if there is no numbers entered in it. Otherwise, the program
(upon execution) gives an error for the StDev function because there is
nothing in the range to calculate.

here is the code so far... thank you for helping!

Sub calc_mean()
Dim J As Integer
Dim K As Integer
Dim rng As Range

' Calculation of standard deviation and mean.

For J = 4 To 192
For K = 0 To 7
Set rng = Range("D" & J + K, "O" & J + K)
If Application.WorksheetFunction.IsNumber(rng) = True Then

Cells(J + K, "R") = Application.WorksheetFunction.Average(rng)
Cells(J + K, "S") = Application.WorksheetFunction.StDev(rng)
End If

Next K
J = J + 10
Next J
End Sub


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using a range with isnumber property


mr ogilvy, i really appreciate the help you provide.

THANK YOU!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

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
Unable to set the FormulaArrary property of the range class RTK Excel Worksheet Functions 0 April 13th 10 08:38 AM
Value/IsNumber/Brackets..? cell equal to range w/o Average nastech Excel Discussion (Misc queries) 2 March 29th 06 12:47 AM
offset property to define range Art[_5_] Excel Programming 2 October 24th 03 08:31 PM
Can Range.Find search a Cells' Text property? clarence_rollins Excel Programming 2 August 25th 03 12:20 AM
Unable to set the Locked Property of the Range Class Stuart[_5_] Excel Programming 0 July 15th 03 06:59 PM


All times are GMT +1. The time now is 03:14 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"