|
楼主 |
发表于 2022-12-6 22:22
|
显示全部楼层
本帖最后由 枫丹白露 于 2022-12-6 22:24 编辑
老师,请移步此贴,帮我看一下这段代码要怎么摆放,才能使 点是的时候,录入数据,点否的时候,不录入数据,谢谢
Private Sub ListBox1_Click()
Dim r, j
With ListBox1
MsgBox .List(0, 2) & ":" & .List(.ListIndex, 2) & vbCrLf _
& .List(0, 3) & ":" & .List(.ListIndex, 3) & vbCrLf _
& .List(0, 4) & ":" & .List(.ListIndex, 4) & vbCrLf _
& .List(0, 5) & ":" & Format(.List(.ListIndex, 5), "#,###0.00") & vbCrLf _
& .List(0, 6) & ":" & .List(.ListIndex, 6) & vbCrLf _
& .List(0, 7) & ":" & .List(.ListIndex, 7) & vbCrLf _
& vbCrLf _
& vbCrLf _
& "是否录入该工时?", vbExclamation + vbYesNo, "工时要素"
End With
If response = vbYes Then 这个位置不对,还是代码不对?点是,也不录入
With ActiveSheet
r = .Range("f" & Range("F:F").Find("合计").Row).End(xlUp).Row + 1
For j = 1 To 4
.Cells(r, j) = ListBox1.List(ListBox1.ListIndex, j - 1)
Next
For j = 6 To 7
.Cells(r, j) = ListBox1.List(ListBox1.ListIndex, j - 2)
Next
End With
Else
response = vbNo 这个代码也是不对,但不知道要怎么放
End If
End Sub |
|