Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default using the slope function with non contiguous cells

Is there a way to use non contiguous cells with the slope function?
Specifically, if y's and x's contain non contiguous values.

SLOPE(known_y's,known_x's)

A simple example...

x's y's
1 10
2 12
3 30
4 32
5 60
6 68

Where...
desired x's = 1, 3, 5
desired y's = 10, 30, 60


Thanks,

-Zack
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default using the slope function with non contiguous cells

use this UDF

=skipslope(A1:A10,B1:B10,3)

where the last number is the step size you want. In you example it will be 2


Function skipslope(ByRef x_values, ByRef y_values, slope_step)
Dim X_range() As Variant
Dim Y_range() As Variant

ReDim X_range(x_values.Count)
ReDim Y_range(y_values.Count)

Index = 0
For i = 1 To x_values.Count Step slope_step
a = x_values(i)

X_range(Index) = x_values(i)
Y_range(Index) = y_values(i)
Index = Index + 1
Next i
skipslope = WorksheetFunction.Slope(X_range, Y_range)


End Function

"fallowfz" wrote:

Is there a way to use non contiguous cells with the slope function?
Specifically, if y's and x's contain non contiguous values.

SLOPE(known_y's,known_x's)

A simple example...

x's y's
1 10
2 12
3 30
4 32
5 60
6 68

Where...
desired x's = 1, 3, 5
desired y's = 10, 30, 60


Thanks,

-Zack

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default using the slope function with non contiguous cells

On May 28, 2:36*pm, Joel wrote:
use this UDF

=skipslope(A1:A10,B1:B10,3)

where the last number is the step size you want. *In you example it will be 2

Function skipslope(ByRef x_values, ByRef y_values, slope_step)
Dim X_range() As Variant
Dim Y_range() As Variant

ReDim X_range(x_values.Count)
ReDim Y_range(y_values.Count)

Index = 0
For i = 1 To x_values.Count Step slope_step
a = x_values(i)

* *X_range(Index) = x_values(i)
* *Y_range(Index) = y_values(i)
* *Index = Index + 1
Next i
skipslope = WorksheetFunction.Slope(X_range, Y_range)

End Function



"fallowfz" wrote:
Is there a way to use non contiguous cells with the slope function?
Specifically, if y's and x's contain non contiguous values.


SLOPE(known_y's,known_x's)


A simple example...


x's * * * *y's
1 *10
2 *12
3 *30
4 *32
5 *60
6 *68


Where...
desired x's = 1, 3, 5
desired y's = 10, 30, 60


Thanks,


-Zack- Hide quoted text -


- Show quoted text -


Thanks Joel...this looks like it will work when there is an ordered
spacing between the cells. Any ideas for when the order would be
random?

-Zack
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default using the slope function with non contiguous cells

The only place I would think that random spacing would be required if there
was a timer stamp on each row where data would be placed in the spreadsheet
everytime the data changed, but you wanted to plot the data at specifc
timestamps.

I would use the tiomestamp to help select the desire rows.

The best way to randomly select data is to add three additional columns to
your data. One is an index which is to number the rows from 1 to last row in
order. The reason for this is to return the data to the original order. the
add random numbers to a second new column. Sort by random number. Then mark
the number of rows you want to sample in the third new column. If you have
100 rows of data and you want to sample 15 random pieces of data then add a 1
to the third new column. then use the index column to return the data to the
original order. then you can modify original UDF code to pass the third new
column to use to select which rows of data to use.

If you need help let me know.

"fallowfz" wrote:

On May 28, 2:36 pm, Joel wrote:
use this UDF

=skipslope(A1:A10,B1:B10,3)

where the last number is the step size you want. In you example it will be 2

Function skipslope(ByRef x_values, ByRef y_values, slope_step)
Dim X_range() As Variant
Dim Y_range() As Variant

ReDim X_range(x_values.Count)
ReDim Y_range(y_values.Count)

Index = 0
For i = 1 To x_values.Count Step slope_step
a = x_values(i)

X_range(Index) = x_values(i)
Y_range(Index) = y_values(i)
Index = Index + 1
Next i
skipslope = WorksheetFunction.Slope(X_range, Y_range)

End Function



"fallowfz" wrote:
Is there a way to use non contiguous cells with the slope function?
Specifically, if y's and x's contain non contiguous values.


SLOPE(known_y's,known_x's)


A simple example...


x's y's
1 10
2 12
3 30
4 32
5 60
6 68


Where...
desired x's = 1, 3, 5
desired y's = 10, 30, 60


Thanks,


-Zack- Hide quoted text -


- Show quoted text -


Thanks Joel...this looks like it will work when there is an ordered
spacing between the cells. Any ideas for when the order would be
random?

-Zack

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using the slope function with non contiguous cells

What decides that they are the desired x's and y's? That their row numbers
are odd numbers? That the x's are evenly divisible by 10? That you like the
way they looked? What is the rule you are using to decide on their
desirability?

Rick


"fallowfz" wrote in message
...
Is there a way to use non contiguous cells with the slope function?
Specifically, if y's and x's contain non contiguous values.

SLOPE(known_y's,known_x's)

A simple example...

x's y's
1 10
2 12
3 30
4 32
5 60
6 68

Where...
desired x's = 1, 3, 5
desired y's = 10, 30, 60


Thanks,

-Zack




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default using the slope function with non contiguous cells

The ranges must be contiguous.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"fallowfz" wrote in message
...
Is there a way to use non contiguous cells with the slope function?
Specifically, if y's and x's contain non contiguous values.

SLOPE(known_y's,known_x's)

A simple example...

x's y's
1 10
2 12
3 30
4 32
5 60
6 68

Where...
desired x's = 1, 3, 5
desired y's = 10, 30, 60


Thanks,

-Zack



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
using slope function with non contiguous cells fallowfz Excel Worksheet Functions 1 May 28th 08 07:51 PM
slope function with matrix columns as arguments adam_6242 Excel Programming 2 July 18th 07 08:01 PM
Anomolous behaviour of slope function. ChasX Excel Worksheet Functions 2 March 5th 06 09:16 PM
Calculating slope, intercept, LOGEST with empty cells in data Rich Excel Worksheet Functions 1 November 23rd 05 04:27 AM
how can i get the slope function to ignore missing data? Delmar Excel Discussion (Misc queries) 0 December 2nd 04 05:55 PM


All times are GMT +1. The time now is 04:14 AM.

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"