读书人

怎么将满足条件的行置顶

发布时间: 2012-03-02 14:40:29 作者: rapoo

如何将满足条件的行置顶
举例说明比较直接:
表格
A 1 true
B 2 True
C 3 False
D 4 True
F 5 False
现在想在表格上添加一个按钮,按钮事件就是点了以后将第三列等于False的行置顶,变成
C 3 False
F 5 False
A 1 true
B 2 True
D 4 True

[解决办法]

VB code
Sub Button1_Click()Dim i As IntegerFor i = 2 To ActiveSheet.UsedRange.Rows.Count Step 1    If Cells(i, 15).Value = "OPEN-TOP" Then        Rows(i).Select        Cells(i, 1).Activate        Selection.Cut        Range("A1").Activate        Selection.Insert Shift:=xlDown    End IfNextEnd Sub 

读书人网 >VBA

热点推荐