close

Sub Macro1()
'
' Macro1 Macro
   
    Cells.Select
    'ActiveWorkbook.Worksheets("scrn513").Sort.SortFields.Clear
    my_rows = Sheets(1).UsedRange.Rows.Count
    my_cols = Sheets(1).UsedRange.Columns.Count
    'myRowCount = Range("A1").CurrentRegion.Rows.Count

    '  Range("A" & x1x & ":B" & x1x & "")
    'ActiveWorkbook.Worksheets("scrn513").Sort.SortFields.Add Key:=Range("J2:J" & my_rows & ""), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    'With ActiveWorkbook.Worksheets("scrn513").Sort
    '    .SetRange Range("A1:S" & my_rows & "")
     '   .Header = xlYes
      '  .MatchCase = False
       ' .Orientation = xlTopToBottom
        '.SortMethod = xlPinYin
        '.Apply
    'End With
   
    For i = 1 To my_cols
        If (Cells(1, i).Value = "買量") Or (Cells(1, i).Value = "賣量") Then
            Columns(i).Delete Shift:=xlLeft '刪除後資料往左移一欄
            my_cols = my_cols - 1
            i = i - 1
        End If
        If Cells(1, i).Value = "漲跌幅(%)" Then
            act_cols = i
        End If
        If i = my_cols - 1 Then
           Exit For
        End If
    Next i
   
    Range("B2").Select
    ActiveWindow.FreezePanes = True
   
    'For i = 200 To 300
   
    For i = 2 To my_rows
        If Abs(Cells(i, act_cols)) < 0.04 Then
            Rows(i).Delete Shift:=xlUp
            my_rows = Sheets(1).UsedRange.Rows.Count
            'my_rows = my_rows - 1
            Debug.Print "---" & i & "***" & my_rows & "$$$" & Abs(Cells(i, 10).Value) & "***"
            i = i - 1
            'MsgBox ("登錄未完成 請再確認")
        End If
        Debug.Print "@@@" & i & "***" & my_rows & "***"
        If i = my_rows - 1 Then
           Exit For
        End If
    Next i
    Columns(2).ColumnWidth = 12
    Columns(3).ColumnWidth = 6
    Columns(4).ColumnWidth = 6
    Columns(act_cols + 2).ColumnWidth = 14   '標的名稱
    Columns(act_cols + 3).ColumnWidth = 10
    Columns(act_cols + 4).ColumnWidth = 6
    Debug.Print "^^^" & "***" & act_cols & "***"
    'ActiveWorkbook.Save
End Sub

 

arrow
arrow
    全站熱搜

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