从不同的工作簿排序

时间:2014-06-03 07:23:55

标签: excel vba excel-vba

我不是VBA宏程序员,但我只知道一点点。请帮我解决这个问题。
有两个工作簿,WorkBookA和WorkBookB。

WorkbookA:

WorkBookB:

BROWSE选项卡用于浏览WorkBookA,其他Workbook whisch与WorkBookA类似,但内容不同。 REFRESH按钮将更新CheckButton的'Checked'或'Unchecked'状态。

1 个答案:

答案 0 :(得分:0)

不太清楚......如果你只想复制检查的数据,你可以写一个像这样的子:

Sub UpdateCheck()
    Dim e, i As Integer

    i = 1
    If CheckBox1.Value Then
        Range("J" & i).Value = CheckBox1.Caption
        i = i + 1
    End If
    If CheckBox2.Value Then
        Range("J" & i).Value = CheckBox2.Caption
        i = i + 1
    End If
    If CheckBox3.Value Then
        Range("J" & i).Value = CheckBox3.Caption
        i = i + 1
    End If
    If CheckBox4.Value Then
        Range("J" & i).Value = CheckBox4.Caption
        i = i + 1
    End If
    If CheckBox5.Value Then
        Range("J" & i).Value = CheckBox5.Caption
        i = i + 1
    End If
    If CheckBox6.Value Then
        Range("J" & i).Value = CheckBox6.Caption
        i = i + 1
    End If
    If CheckBox7.Value Then
        Range("J" & i).Value = CheckBox7.Caption
        i = i + 1
    End If
    If CheckBox8.Value Then
        Range("J" & i).Value = CheckBox8.Caption
        i = i + 1
    End If

    For e = i To 8
        Range("J" & e).Value = ""
    Next

End Sub

此示例位于同一页面上,但您只需要在范围

中添加引用
Sheets(2).Range ...

您可以直接在Sheet2中的按钮上调用子UpdateCheck。或者您可以自动添加代码:

Private Sub CheckBox1_Click()
   UpdateCheck
End Sub

表单中的每个复选框。
如果你想用来从更大的数据中复制或在过滤器中使用,那就更复杂了...... 我不明白使用BROWSE Button ......