|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
116632880 发表于 2014-4-14 15:55 
Private Sub ListBox1_Click()
b = Sheets("录入表").Range("c65536").End(xlUp).Row
Set a ...
将上面的代码改为以下代码后,3个问题均可解决:
Private Sub ListBox1_Click()
If Left(ListBox1.Value, 4) & ";" = Year(Date) & ";" Then
Set a = Sheets("录入表").Cells.Find(ListBox1.List(ListBox1.ListIndex, 1))
For i = 2 To 5
If i <> 4 Then Sheet1.Cells(ActiveCell.Row, i) = a.Offset(0, i - 2)
Next i
Else
Set a = Sheets("录入表").Cells.Find(ListBox1.List(ListBox1.ListIndex))
For i = 1 To 5
If i <> 3 Then Sheet1.Cells(ActiveCell.Row, i + 1) = a.Offset(0, i - 1)
Next i
End If
End Sub |
|