我使用1个按钮和1个spinButton。这些按钮用于导航我的工作簿。
按钮用于导航到我的目录,旋转按钮向上是下一页,旋转按钮用于上一页。但我有一个问题。我有3张。在第二张纸上是一个文本框,里面有一些文字。我点击下一页的旋钮,第3页激活,但我看到了表2的文本框。所以我认为excel需要刷新或什么?
我的代码将工作表中的一些对象带到下一张工作表。当我点击下面的表格时,我没有遇到这个问题。只有当我点击我的旋钮时,某些物体才会出现在下一张纸上,但它们应该保留在前一张纸上。当我看到它们时,我无法点击它们。这就像是excel的刷新错误。
我希望你们能解决我的问题。在这里,您可以看到我的代码,用于在带有旋钮和命令按钮
的工作表之间导航 Sub volgendePagina()
Dim wb As Workbook
Dim lSheets As Long
Dim lSheet As Long
Dim lMove As Long
Dim lNext As Long
Set wb = ActiveWorkbook
lSheets = wb.Sheets.Count
lSheet = ActiveSheet.Index
lMove = 1
With wb
For lMove = 1 To lSheets - 1
lNext = lSheet + lMove
If lNext > lSheets Then
lMove = 0
lNext = 1
lSheet = 1
End If
If .Sheets(lNext).Visible = True Then
.Sheets(lNext).Activate
Exit For
End If
Next lMove
End With
End Sub
Sub vorigePagina()
Dim wb As Workbook
Dim lSheets As Long
Dim lSheet As Long
Dim lMove As Long
Dim lNext As Long
Set wb = ActiveWorkbook
lSheets = wb.Sheets.Count
lSheet = ActiveSheet.Index
lMove = 1
With wb
For lMove = 1 To lSheets - 1
lNext = lSheet - lMove
If lNext < 1 Then
lMove = 0
lNext = lSheets
lSheet = lSheets
End If
If .Sheets(lNext).Visible = True Then
.Sheets(lNext).Activate
Exit For
End If
Next lMove
End With
End Sub
Public Sub inhoudsTafel()
ThisWorkbook.Sheets(1).Activate
End Sub
答案 0 :(得分:0)
您可以尝试以下代码:
Sub volgendePagina()
Dim i as Long
i = ActiveSheet.Index
do
i = i Mod ActiveWorkbook.Sheets.Count +1
loop until ActiveWorkbook.Sheets(i).Visible
ActiveWorkbook.Sheets(lNext).Activate
End Sub
Sub vorigePagina()
Dim i as Long
i = ActiveSheet.Index
do
i = i - 1
if i < 1 the i = ActiveWorkbook.Sheets.Count
loop until ActiveWorkbook.Sheets(i).Visible
ActiveWorkbook.Sheets(lNext).Activate
End Sub
Public Sub inhoudsTafel()
ThisWorkbook.Sheets(1).Activate
'note: ThisWorkbook = the workbook which contains this code
'ActiveWorkbook = well... the currently active workbook :)
End Sub