|
楼主 |
发表于 2018-7-10 16:45
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
由于listview控件不支持64位的Excel,因此想用listbox控件替换,请大神修改代码,谢谢!
Private Sub UserForm_Initialize()
Dim lvw
Dim i As Long, m As Long
ListView1.ColumnHeaders.Add 1, , "图号", ListView1.Width * 0.2
ListView1.ColumnHeaders.Add 2, , "存放位置", ListView1.Width * 0.1
ListView1.ColumnHeaders.Add 3, , "物料编码", ListView1.Width * 0.05
ListView1.ColumnHeaders.Add 4, , "名称", ListView1.Width * 0.15
ListView1.ColumnHeaders.Add 5, , "规格型号", ListView1.Width * 0.1
ListView1.ColumnHeaders.Add 6, , "单位", ListView1.Width * 0.05
ListView1.ColumnHeaders.Add 7, , "单价", ListView1.Width * 0.05
ListView1.ColumnHeaders.Add 8, , "实际库存数量", ListView1.Width * 0.15
ListView1.ColumnHeaders.Add 9, , "理论库存数量", ListView1.Width * 0.15
With Sheet5
For i = 6 To .[a65536].End(xlUp).Row
Set lvw = ListView1.ListItems.Add()
lvw.Text = .Cells(i, 1)
For m = 2 To 7
lvw.SubItems(m - 1) = .Cells(i, m)
Next m
lvw.SubItems(7) = .Cells(i, 14)
lvw.SubItems(8) = .Cells(i, 16)
Next i
End With
End Sub
Private Sub ListView1_DblClick()
Application.ScreenUpdating = False
Application.Calculation = xlManual
Dim j As Long, m As Long
Dim lvw
With Sheet2
j = .[a65536].End(xlUp).Row + 1
If TextBox2.Value <> "" Then
.Cells(j, 1) = ListView1.SelectedItem.Text
For m = 2 To 7
.Cells(j, m) = ListView1.SelectedItem.SubItems(m - 1)
Next m
.Cells(j, 8) = TextBox2.Value
.Cells(j, 9) = VBA.Format(Now(), "yyyy-mm-dd")
.Cells(j, 10) = .Cells(j, 7) * .Cells(j, 8)
.Cells(j, 11) = TextBox3.Value
.Cells(j, 12) = Sheet1.Range("d2")
Else
MsgBox "请输入数量", vbInformation, "系统提示"
End If
End With
TextBox1.SetFocus
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
ThisWorkbook.Save
End Sub |
|