Purpose
(I can't remember very exactly so just waiting for rearrangement)
Sub DassyChain()
'by Franklin.Q 2008-12-09
Dim iRow, iCol, RowCt, ColCt, i, j, k As Integer
Dim Sum As Double
RowCt = ActiveWorkbook.ActiveSheet.UsedRange.Rows.Count
ColCt = ActiveWorkbook.ActiveSheet.UsedRange.Columns.Count
iRow = RowCt
iCol = ColCt + 1
k = 1
rSheet = ActiveSheet.Index
w = ActiveWorkbook.Worksheets.Count
Worksheets.Add After:=Worksheets(w)
Worksheets(rSheet).Select
For j = 1 To iCol
Select Case Judge(j)
Case 1
Cells(1, j) = "V"
Case 2
Cells(1, j) = "I"
Case 3
Cells(1, j) = "R"
For i = 1 To iRow
Cells(i + 1, j).Value = Cells(i + 1, j - 2).Value / Cells(i + 1, j - 1).Value
Sum = Sum + Cells(i + 1, j).Value
Next i
Cells(iRow + 2, j).Value = Sum / (iRow - 1)
Sum = 0
Worksheets(w + 1).Cells(k, 1).Value = Cells(iRow + 2, j).Value
k = k + 1
End Select
Next j
Worksheets(w + 1).Select
End Sub
Function Judge(n) As Integer
If n > 3 Then
Select Case (n Mod 3)
Case 0
Judge = 3
Case 1
Judge = 1
Case 2
Judge = 2
End Select
Else
Judge = n
End If
End Function
No comments:
Post a Comment