举例说明比较直接:
表格
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