我正在构建一个宏来将选定的行从工作表复制到选定的工作表.例如,我想将第3,5,6,7行复制到工作表3.我曾想过使用复选框选择行和单选按钮来选择工作表.在我的代码中,我通过单选按钮设置变量,该变量用于决定必须复制数据的工作表.
Public Val As String
Public Sub OptionButton1_Click()
If OptionButton1.Value = True Then Val = "Sheet2"
End Sub
Public Sub OptionButton2_Click()
If OptionButton2.Value = True Then Val = "Sheet3"
End Sub
Sub Addcheckboxes()
Dim cell, LRow As Single
Dim chkbx As CheckBox
Dim MyLeft, MyTop, MyHeight, MyWidth As Double
Application.ScreenUpdating = False
LRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For cell = 2 To LRow
If Cells(cell, "A").Value <> "" Then
MyLeft = Cells(cell, "E").Left
MyTop = Cells(cell, "E").Top
MyHeight = Cells(cell, …Run Code Online (Sandbox Code Playgroud)