当前位置: 代码迷 >> VBA >> 怎么将满足条件的行置顶
  详细解决方案

怎么将满足条件的行置顶

热度:9341   发布时间:2013-02-26 00:00:00.0
如何将满足条件的行置顶
举例说明比较直接:
表格
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
  相关解决方案