VBA/Excelシート移動
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
''[[TopPage]]''
* Excelシート移動 [#x91f3ceb]
Ctrl+PgUp、Ctrl+PgDnで移動するのは面倒で遅いため、マクロ...
prevSheetにCtrl+q、nextSheetにCtrl+eをショートカットとし...
** 2019/10/15 改良版 [#nbaffbc1]
Sub prevSheet()
Set SH = ActiveWorkbook.ActiveSheet
Set STS = ActiveWorkbook.Sheets
On Error Resume Next
''左のシートへ。最初なら末尾に
If SH.Name = STS(1).Name Then
STS(STS.Count).Activate
Else
''非表示のシートは飛ばす
Do While SH.Previous.Visible <> xlSheetVisible
If Err <> 0 Then Exit Do
Set SH = SH.Previous
Loop
If SH.Previous.Visible <> xlSheetVisible And...
STS(STS.Count).Activate
Else
SH.Previous.Activate
End If
On Error GoTo 0
End If
End Sub
Sub nextSheet()
Set SH = ActiveWorkbook.ActiveSheet
Set STS = ActiveWorkbook.Sheets
On Error Resume Next
''右のシートへ。末尾なら最初に
If SH.Name = STS(STS.Count).Name Then
STS(1).Activate
Else
''非表示のシートは飛ばす
Do While SH.Next.Visible <> xlSheetVisible
If Err <> 0 Then Exit Do
Set SH = SH.Next
Loop
If SH.Next.Visible <> xlSheetVisible And SH....
STS(1).Activate
Else
SH.Next.Activate
End If
On Error GoTo 0
End If
End Sub
** シンプル初期版 [#a2f747d6]
Sub prevSheet()
If 1 < ActiveSheet.Index Then ' ...
ActiveSheet.Previous.Select ...
End If
End Sub
Sub nextSheet()
If Worksheets.Count > ActiveSheet.Index Then ' ...
ActiveSheet.Next.Select ...
End If
End Sub
*** 参考ページ [#x466ae40]
~
終了行:
''[[TopPage]]''
* Excelシート移動 [#x91f3ceb]
Ctrl+PgUp、Ctrl+PgDnで移動するのは面倒で遅いため、マクロ...
prevSheetにCtrl+q、nextSheetにCtrl+eをショートカットとし...
** 2019/10/15 改良版 [#nbaffbc1]
Sub prevSheet()
Set SH = ActiveWorkbook.ActiveSheet
Set STS = ActiveWorkbook.Sheets
On Error Resume Next
''左のシートへ。最初なら末尾に
If SH.Name = STS(1).Name Then
STS(STS.Count).Activate
Else
''非表示のシートは飛ばす
Do While SH.Previous.Visible <> xlSheetVisible
If Err <> 0 Then Exit Do
Set SH = SH.Previous
Loop
If SH.Previous.Visible <> xlSheetVisible And...
STS(STS.Count).Activate
Else
SH.Previous.Activate
End If
On Error GoTo 0
End If
End Sub
Sub nextSheet()
Set SH = ActiveWorkbook.ActiveSheet
Set STS = ActiveWorkbook.Sheets
On Error Resume Next
''右のシートへ。末尾なら最初に
If SH.Name = STS(STS.Count).Name Then
STS(1).Activate
Else
''非表示のシートは飛ばす
Do While SH.Next.Visible <> xlSheetVisible
If Err <> 0 Then Exit Do
Set SH = SH.Next
Loop
If SH.Next.Visible <> xlSheetVisible And SH....
STS(1).Activate
Else
SH.Next.Activate
End If
On Error GoTo 0
End If
End Sub
** シンプル初期版 [#a2f747d6]
Sub prevSheet()
If 1 < ActiveSheet.Index Then ' ...
ActiveSheet.Previous.Select ...
End If
End Sub
Sub nextSheet()
If Worksheets.Count > ActiveSheet.Index Then ' ...
ActiveSheet.Next.Select ...
End If
End Sub
*** 参考ページ [#x466ae40]
~
ページ名: