|
楼主 |
发表于 2017-9-4 09:51
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 zjdh 于 2017-9-5 13:46 编辑
你若会打开宏的话,将“单据录入”页的这段宏修改为如下内容,因6-4.8你都无法使用,可能我修改好的附件你也不能使用。
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim I As Integer, arr1()
If Target.Count = 1 Then
If Target.Address = "$D$3" Then
Arrsj = Sheets("基础信息表").Range("J2:J" & Sheets("基础信息表").[J65536].End(xlUp).Row)
TextBox2.Activate
TextBox2 = ""
With Me.TextBox2
.Visible = True
.Top = Target.Top
.Left = Target.Left
.Width = Target.Width
.Height = Target.Height
End With
With Me.ListBox2
.Visible = True
.Top = Target.Top
.Left = Target.Left + Target.Width
.Width = Target.Width * 2
.Height = Target.Height * 4
For I = 1 To UBound(Arrsj)
If Arrsj(I, 1) <> "" Then
k = k + 1
ReDim Preserve arr1(1 To k)
arr1(k) = Arrsj(I, 1)
End If
Next I
If k = 0 Then Exit Sub
.List = Application.Transpose(arr1)
End With
Else
Me.ListBox2.Clear
Me.TextBox2 = ""
Me.ListBox2.Visible = False
Me.TextBox2.Visible = False
End If
If Target.Column = 3 And Target.Row > 5 Then
Arrsj = Sheets("基础信息表").Range("A2:H" & Sheets("基础信息表").[H65536].End(xlUp).Row)
TextBox1.Activate
TextBox1 = ""
With Me.TextBox1
.Visible = True
.Top = Target.Top
.Left = Target.Left
.Width = Target.Width
.Height = Target.Height
End With
With Me.ListBox1
.Visible = True
.Top = Target.Top
.Left = Target.Left + Target.Width
.Width = Target.Width * 5
.Height = Target.Height * 4
arr2 = Array("编 码", "物 品 名 称", "规格型号", "单位")
k = k + 1
ReDim Preserve arr1(1 To 4, 1 To k)
For I = 1 To 4
arr1(I, k) = arr2(I - 1)
Next
For I = 1 To UBound(Arrsj)
If Arrsj(I, 1) <> "" Then
k = k + 1
ReDim Preserve arr1(1 To 4, 1 To k)
For t = 1 To 4
arr1(t, k) = Arrsj(I, t)
Next
End If
Next I
If k = 1 Then Exit Sub
.List = Application.Transpose(arr1)
End With
Else
Me.ListBox1.Clear
Me.TextBox1 = ""
Me.ListBox1.Visible = False
Me.TextBox1.Visible = False
End If
End If
End Sub
|
|