mathgirl09
New Member
- Joined
- Jun 4, 2015
- Messages
- 10
Hi, I would like to know what code I'm supposed to use to be able to create a function by dividing the smallest value by the largest one by selecting 2 cells within the range each time until the last value in the range. For example:
<tbody>
</tbody>
I want to select the cells from A1 to A5 containing the values as noted (A1=50, ..., A5=40) and I would like to select 2 cells everytime in that range so: selecting A1 and A2 and divide the smallest value by the largest : A2/A1 (= 48/50); then select A2 and A3, and divide A3 by A2 (=45/48) and so on.
I tried:
A1 | 50 |
A2 | 48 |
A3 | 45 |
A4 | 42 |
A5 | 40 |
<tbody>
</tbody>
I want to select the cells from A1 to A5 containing the values as noted (A1=50, ..., A5=40) and I would like to select 2 cells everytime in that range so: selecting A1 and A2 and divide the smallest value by the largest : A2/A1 (= 48/50); then select A2 and A3, and divide A3 by A2 (=45/48) and so on.
I tried:
Code:
Function ratio(ByVal nb1 As Single, ByVal nb2 As Single) As Single
If nb2 > nb1 Then
ratio = nb1 / nb2
Else
Choose nb2 > nb1
End If
End Function