|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
求助优化代码缩短运行时间,附件中的“入库单” C 列是由ListBox控件逐步提示信息录入的,双击信息录入到工作表中,下面的代码运行时间较长要15秒,现求助各位老师帮忙优化一下代码,达到缩短运行时间的效果。
求助优化代码.rar
(335.11 KB, 下载次数: 13)
Private Sub ListBOX1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) '双击录入
tms = Timer
ActiveCell.Offset(0, -1) = Me.ListBox1.List(Me.ListBox1.ListIndex, 16)
ActiveCell.Offset(0, 0) = Me.ListBox1.List(Me.ListBox1.ListIndex, 0)
ActiveCell.Offset(0, 1) = Me.ListBox1.List(Me.ListBox1.ListIndex, 5)
ActiveCell.Offset(0, 2) = Me.ListBox1.List(Me.ListBox1.ListIndex, 6)
ActiveCell.Offset(0, 3) = Me.ListBox1.List(Me.ListBox1.ListIndex, 7)
ActiveCell.Offset(0, 4) = Me.ListBox1.List(Me.ListBox1.ListIndex, 9)
ActiveCell.Offset(0, 5) = Me.ListBox1.List(Me.ListBox1.ListIndex, 10)
ActiveCell.Offset(0, 6) = Me.ListBox1.List(Me.ListBox1.ListIndex, 18)
ActiveCell.Offset(0, 7).Value = Sheet1.Cells(ActiveCell.Offset(0, -1).Value, 77).Value
ActiveCell.Offset(0, 8).Value = Sheet1.Cells(ActiveCell.Offset(0, -1).Value, 85).Value
ActiveCell.Offset(0, 9).Value = Abs(Sheet1.Cells(ActiveCell.Offset(0, -1).Value, 86).Value)
ActiveCell.Offset(0, 10).Value = Sheet1.Cells(ActiveCell.Offset(0, -1).Value, 22).Value
ActiveCell.Offset(0, 11).Value = Sheet1.Cells(ActiveCell.Offset(0, -1).Value, 39).Value
ActiveCell.Offset(0, 12).Value = Abs(Sheet1.Cells(ActiveCell.Offset(0, -1).Value, 40).Value)
Me.ListBox1.Clear
Me.TextBox1 = ""
Me.ListBox1.Visible = False
Me.TextBox1.Visible = False
ActiveCell.Offset(, 8).Select
MsgBox Format(Timer - tms, "0.0000s")
End Sub
|
|