|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 无毒无偶 于 2012-4-10 16:21 编辑
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- Dim Sh1 As Worksheet
- Set Sh1 = Worksheets("Sheet1")
- If TypeName(ActiveSheet) = "Worksheet" And TypeName(ActiveCell) = "Range" And VarType(ActiveCell) <= 5 Then
- MActRow# = ActiveCell.Row
- If ActiveCell.Column = 1 And MActRow > 0 And MActRow <= 9 And ActiveCell > 0 And ActiveCell <= 30 Then
- NSelected% = ActiveCell
- ListWid! = 0
- ListCW$ = ""
- For i = 1 To 3
- ListWid = ListWid + Sh1.Columns(12 + i).Width
- ListCW = IIf(ListCW = "", Sh1.Columns(12 + i).Width & ";", ListCW & Sh1.Columns(12 + i).Width & ";")
- Next i
-
- ListHgt% = IIf(NSelected + 1 < 22, (NSelected + 1) * 9 + 3, 21 * 9 + 3)
-
- Unload UserForm1
- With UserForm1
- .Width = ListWid + 6
- .Height = ListHgt + 22
- End With
- UserForm1.Show vbModeless
- With UserForm1.ListBox1
- .ColumnCount = 3
- .ColumnWidths = ListCW
- .RowSource = Sh1.Range("M1:O" & (NSelected + 1)).Address
- .Width = ListWid + 3
- .Height = ListHgt
- End With
- MsgBox " " '如果注释掉此行,显示的ListBox将显示不正常;另外注释掉此行后,如果第N列列宽较小时又显示正常
- End If
- End If
- End Sub
复制代码 把窗体显示放前面就正常了,具体为什么,不得而知。
|
|