|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Public d As Object
- Private Sub cmd_exit_Click()
- Unload UserForm1
- End Sub
- Private Sub cmd_ok_Click()
- Dim r%, i%
- Dim rng As Range
- Dim ws As Worksheet
- With UserForm1
- If .TextBox1 = "" And .TextBox2 = "" Then
- MsgBox "住院号和姓名不能都为空!"
- Exit Sub
- End If
- If d.exists(.TextBox1.Text) Then
- MsgBox d(.TextBox1.Text)
- ElseIf d.exists(.TextBox2.Text) Then
- MsgBox d(.TextBox2.Text)
- End If
- End With
- End Sub
- Private Sub UserForm_Initialize()
- Dim r%, i%
- Dim arr, brr
- Dim ws As Worksheet
- Set d = CreateObject("scripting.dictionary")
- For Each ws In Worksheets
- If ws.Name Like "####-####" Then
- With ws
- r = .Cells(.Rows.Count, 2).End(xlUp).Row
- arr = .Range("a2:i" & r)
- For i = 1 To UBound(arr)
- If Len(arr(i, 1)) <> 0 Then
- xm = arr(i, 1)
- End If
- For j = 2 To UBound(arr, 2) Step 2
- If IsNumeric(arr(i, j)) Then
- d(CStr(arr(i, j))) = xm
- d(arr(i, j + 1)) = xm
- End If
- Next
- Next
- End With
- End If
- Next
- End Sub
复制代码 |
|