LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Counting elements of array and range type data

I've got the following function that I would like to make versatile enough
that I can use it within VBA code and as a simple excel worksheet function.
I've pasted the function here where I'm having trouble, I need to figure out
how to count the elements in the range for both types of data. The "Size"
variable where I'm getting the dimension works with the UBound if my data
type is an array or variant, but I have to use Xrange.Count if the data is an
excel workbook range. Neither option works for both instances. Here is my
code:

Sub TestFunc()
Dim Test1(3) As Single, Test2(3) As Single, Value As Single, Value2 As
Single

Test1(1) = 3
Test1(2) = 2
Test1(3) = 1
Test2(1) = 1
Test2(2) = 2
Test2(3) = 3
Value = 2.5

Value2 = interpolate(Value, Test1, Test2)

Worksheets("Input Page").Select
Range("P25") = Value2


End Sub




Function interpolate(Value, xrange, yrange)
' Function linearly interpolates from a given x/y range
' Function allows for extrapolation outside the known range
'
Dim Size As Integer, Cumiminus1 As Single, Cumi As Single
Dim X1 As Single, X2 As Single, Y1 As Single, Y2 As Single
'
' Size = xrange.Count
' Size = 3
Size = UBound(xrange)
'


Thanks, Tom
 
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
Counting the Number of Elements in an Array Confused_in_Houston[_2_] Excel Discussion (Misc queries) 3 October 1st 08 11:05 PM
counting elements of two arrays Geoff[_14_] Excel Programming 6 August 24th 07 09:15 AM
Array loses data type when placed into range Mbtch@. Excel Programming 2 June 7th 05 09:23 PM
What is the maximum allowed number of data elements in a data array? [email protected] Excel Discussion (Misc queries) 2 April 7th 05 06:56 PM
Counting the number of elements within an array that have data ExcelMonkey[_125_] Excel Programming 5 May 26th 04 05:14 PM


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