|
楼主 |
发表于 2024-9-20 17:01
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参照你的思路用activeX控件改了下
Option Explicit
Public rowscount As Long
Public showrows As Integer
Public r As Integer
Private Sub CommandButton1_Click()
Dim RNG As Range
Dim H As Integer
Application.ScreenUpdating = False
rowscount = ActiveSheet.UsedRange.Rows.Count
Set RNG = Range(Cells(2, 1), Cells(rowscount, 3))
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ReDim arr(1 To rowscount, 1 To 3)
arr = RNG
With ActiveSheet.ListBox1 '数据列表
.ListFillRange = "" '清空数据列表
.ColumnCount = 3 '列表设定3列
.ColumnWidths = "60;100;150" '每列宽度
.ColumnHeads = True '默认有标题,标题数据取自源数据第一行的上一行
.ListFillRange = RNG.Address(, , , True) '获取数据
.TopIndex = .ListCount '首行显示的数据
H = .Height '数据列表高度
showrows = Int(H / 12) '大致估算每一页看到的行数,12为每一行的高度
End With
delay
Application.DisplayAlerts = True
End Sub
Private Sub CommandButton2_Click()
On Error Resume Next
Application.OnTime (Now + TimeValue("00:00:01")), "sheet4.delay", , False
End Sub
Sub delay()
With ActiveSheet.ListBox1
'首行显示当前行,每过1秒加1,当当前行等于最后一页的首行时,当前行为0
.TopIndex = r
r = r + 1
If r = rowscount - showrows Then
r = 0
End If
End With
Application.OnTime (Now + TimeValue("00:00:01")), "sheet4.delay"
End Sub
|
|