|
楼主 |
发表于 2022-12-6 21:58
|
显示全部楼层
我不是单纯的只要yes or no
我自己倒腾了下,但无论点是还是否,都不会录入数据了,应该是位置不对
代码:
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 |
|