close

Sub Macro1()
'找出買賣超前十五名券商
' 1.合併同券商之交易 2.累計各券商買賣超 3.排序

Cells.Select
'ActiveWorkbook.Worksheets("scrn513").Sort.SortFields.Clear
my_rows = Sheets(1).UsedRange.Rows.Count
my_cols = Sheets(1).UsedRange.Columns.Count

k = 2
'For i = 2 To 4
For i = 2 To my_rows
Cells(k, 5).Value = Cells(i, 1).Value
Cells(k, 6).Value = Cells(i, 3).Value
Cells(k, 7).Value = Cells(i, 4).Value
chk_value = Cells(i, 1).Value
i = i + 1
'Debug.Print "---" & i & "***" & chk_value & "$$$" & Cells(i, 5).Value & "***"
While Cells(i, 1).Value = chk_value
Cells(k, 6).Value = Cells(k, 6).Value + Cells(i, 3).Value
Cells(k, 7).Value = Cells(k, 7).Value + Cells(i, 4).Value
chk_value = Cells(i, 1).Value
i = i + 1
Wend
Cells(k, 8).Value = (Cells(k, 6).Value - Cells(k, 7).Value) / 1000
k = k + 1 '累計後券商列數
Next i


'Columns(4).ColumnWidth = 6
'ActiveWorkbook.Save
End Sub

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 gniksong 的頭像
    gniksong

    有機小松的部落格

    gniksong 發表在 痞客邦 留言(0) 人氣()