|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
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 |
|