|
楼主 |
发表于 2018-11-13 21:36
|
显示全部楼层
和几个变量,将对应数据赋值给对应单元格,加两三行代码即可
- Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
- On Error Resume Next '
- Dim ls, drr, i, j, k, c, c0, cc, shn As String, ii<font color="red">, kn, ka, sc, da</font>
- ls = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex, 0)
- UserForm1.TextBox1 = ls
- 'If UserForm1.TextBox1.Text <> "" Then
- ' ls = UserForm1.TextBox1.Text
- 'Else
- ' MsgBox "请输入搜索并从列表中双击选择一个单据编号"
- 'End If
- If UserForm1.OptionButton1.Value = True Then
- c = 3
- c0 = 4
- cc = 10
- shn = "送货单"
- ElseIf UserForm1.OptionButton2.Value = True Then
- c = 5
- c0 = 0
- cc = UBound(arr, 2)
- shn = "按订单查询结果"
- End If
- ReDim drr(1 To UBound(arr), 1 To cc)
- For i = 2 To UBound(arr)
- If arr(i, c) = ls Then
- <font color="red"> kn = arr(i, 1)
- ka = arr(i, 2)
- sc = arr(i, 3)
- da = arr(i, 4)</font>
- k = k + 1
- For j = 1 To cc
- drr(k, j) = arr(i, j + c0)
- Next
- End If
- Next
- With Sheets(shn)
- If shn = "送货单" Then
- If k > 8 Then
- For ii = 6 To 100
- If InStr(.Range("A" & ii), "金额合计") Then 'If .Range("A" & ii) = "金额合计(大写):" Then
- .Rows(ii & ":" & ii + k - 8).Insert Shift:=xlDown, copyorigin:=xlFormatFromLeftOrAbove
- Exit For
- End If
- Next
- End If
- <font color="red"> .Range("B3") = kn
- .Range("B4") = ka
- .Range("I3") = sc
- .Range("I4") = da</font>
- .Range("A6:J" & ii).ClearContents
- .Range("A6").Resize(k, UBound(drr, 2)) = drr
- .Activate
- .Range("A6").Select
- ElseIf shn = "按订单查询结果" Then
- .Range("A3:N65536").ClearContents
- .Range("A3").Resize(k, UBound(drr, 2)) = drr
- .Activate
- .Range("A3").Select
- End If
- End With
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|