Sub cb1_Click() Dim i, j, h As Integer Dim r As Range Dim str As String Dim li, lj As Integer lj = 1 'Worksheets(1).Range("c1:c40").Clear For li = 0 To Sheet1.ListBox1.ListCount - 1 'If Sheet1.ListBox1.Selected(i) Then msg = msg & Sheet1.ListBox1.List(i) & vbCrLf If Sheet1.ListBox1.Selected(li) Then 'Sheet1.Cells(lj, 3) = Sheet1.ListBox1.List(li) str = Sheet1.ListBox1.List(li) lj = lj + 1 End If For Each r In Worksheets("设备检测表模").Range("b1:b35") If r.Value = str Then a = r.Row b = r.Column End If 'Next 'If r Is Nothing Then 'MsgBox "请检查输入的设备名称" 'End If i = Worksheets("设备检测表模").Cells.Find("*", , , , xlByRows, xlPrevious).Row j = Worksheets("设备检测表模").Cells(a, Columns.Count).End(xlToLeft).Column j = j + 1 'Worksheets(1).Cells(2, 1) = str Worksheets("设备检测表模").Select Worksheets("设备检测表模").Cells(a, j) = Worksheets(1).Cells(4, 4) Next r Next li End Sub
文章评论