Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Need to calculate the difference between different pairs of values!

Hello! Please help!

I have a column with 20 integers, from 1 to 20. Each integer is
associated with a value in a second column.

These integers represent 20 evenly spaced points along a circle.
Points 1 and 20 are therefore close together, whereas points 1 and 10
are maximally separated.

I need to calculate the difference between the recorded values for
every possible combination of lag distances! Namely,
points with a lag distance of 1 would include (1,2) (2,3) (3,4)
(4,5) ... (20,1)
points with a lag distance of 2 would include (1,3) (2,4) (3,5) (4,6)
(5,7) ... (20,2)
points with a lag distance of 10 (maximal distance!) would include
(1,10) (2,11) (3,12) (4,13) ... (20,10)

I need to present all the calculated differences of my recorded values
in a new column. For each calculated difference I would also need to
know which lag I'm dealing with (1,2, ... 10), perhaps in another
column.

Thank you!

Ilford
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Need to calculate the difference between different pairs of values

Sub Lag_Dist()

'place number in Column A from rows 2 to 21
Total_Numbers = 20
For Lag = 1 To 10
Col_Num = Lag + 1
Cells(1, Col_Num) = "Lag " & Lag
For Num = 0 To (Total_Numbers - 1)
Row_Num = Num + 2
Second_Row_Num = ((Num + Lag) Mod Total_Numbers) + 2
Cells(Row_Num, Col_Num) = _
Range("A" & Row_Num) - Range("A" & Second_Row_Num)
Next Num
Next Lag

End Sub


" wrote:

Hello! Please help!

I have a column with 20 integers, from 1 to 20. Each integer is
associated with a value in a second column.

These integers represent 20 evenly spaced points along a circle.
Points 1 and 20 are therefore close together, whereas points 1 and 10
are maximally separated.

I need to calculate the difference between the recorded values for
every possible combination of lag distances! Namely,
points with a lag distance of 1 would include (1,2) (2,3) (3,4)
(4,5) ... (20,1)
points with a lag distance of 2 would include (1,3) (2,4) (3,5) (4,6)
(5,7) ... (20,2)
points with a lag distance of 10 (maximal distance!) would include
(1,10) (2,11) (3,12) (4,13) ... (20,10)

I need to present all the calculated differences of my recorded values
in a new column. For each calculated difference I would also need to
know which lag I'm dealing with (1,2, ... 10), perhaps in another
column.

Thank you!

Ilford

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
calculate the difference between negative and positive values watty Excel Worksheet Functions 7 May 20th 23 03:45 AM
how to calculate the difference of values (numbers) in a column? Huseyin Excel Worksheet Functions 0 February 18th 10 04:47 AM
Return Consecutive Values - Pairs Sam via OfficeKB.com Excel Worksheet Functions 6 July 2nd 05 04:43 PM
Excel - treat pairs of figures differently according to values Alistair Excel Worksheet Functions 1 May 10th 05 10:31 PM
How do you calculate the difference between two values within a p. emlouise Excel Discussion (Misc queries) 2 December 10th 04 03:13 AM


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