メインコンテンツへスキップ

Excelでワークシートタブをロックまたはフリーズする方法は?

複数のワークシートを含むワークブックがあるとすると、ワークブックの最初のタブとしてMain-sheetという名前のワークシートがあります。 そして今、このシートタブをロックまたはフリーズして、複数のワークシートをスクロールしても常に表示されるようにします。 実際、タブをフリーズする直接的な方法はありませんが、回避策を使用してこの問題に対処することができます。

VBAコードで特定のワークシートタブをロックまたはフリーズします


矢印青い右バブル VBAコードで特定のワークシートタブをロックまたはフリーズします

Excelでは、次のVBAコードを適用して、現在クリックしているワークシートタブの前に常に特定のワークシートを作成できるため、他のシートタブをスクロールしたときにこのワークシートを常に表示できます。 次のようにしてください。

1。 を押し続けます Alt + F11 キー、そしてそれは開きます Microsoft Visual Basic forApplicationsウィンドウ.

2。 それから、 このワークブック 左から プロジェクトエクスプローラー ペインをダブルクリックして開きます モジュール、次に、次のVBAコードをコピーして空のモジュールに貼り付けます。

VBAコード:特定のワークシートタブをフリーズまたはロックする

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
'Update by Extendoffice
Application.EnableEvents = False
Application.ScreenUpdating = False
If Application.ActiveSheet.Index <> Application.Sheets("Main-sheet").Index Then
    Application.Sheets("Main-sheet").Move Before:=Application.Sheets(Application.ActiveSheet.Index)
    Application.Sheets("Main-sheet").Activate
    Sh.Activate
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub

ドキュメントフリーズシートタブ-1

3。 次に、このコードを保存して閉じます。ワークシートタブのいずれかをクリックすると、この特定のワークシートは常にクリックしたシートタブの前面に表示されます。スクリーンショットを参照してください。

ドキュメントフリーズシートタブ-2
-1
ドキュメントフリーズシートタブ-3

Note:上記のコードでは、メインシートはフリーズするシート名です。必要に応じて変更できます。


関連記事:

Excel 2010でペインをフリーズする方法は?

一度に複数のワークシートにフリーズ/フリーズ解除ペインを適用するにはどうすればよいですか?

最高のオフィス生産性向上ツール

🤖 Kutools AI アシスタント: 以下に基づいてデータ分析に革命をもたらします。 インテリジェントな実行   |  コードを生成  |  カスタム数式の作成  |  データを分析してグラフを生成する  |  Kutools関数を呼び出す...
人気の機能: 重複を検索、強調表示、または識別する   |  空白行を削除する   |  データを失わずに列またはセルを結合する   |   数式なしのラウンド ...
スーパールックアップ: 複数の基準の VLookup    複数の値の VLookup  |   複数のシートにわたる VLookup   |   ファジールックアップ ....
詳細ドロップダウン リスト: ドロップダウンリストを素早く作成する   |  依存関係のドロップダウン リスト   |  複数選択のドロップダウンリスト ....
列マネージャー: 特定の数の列を追加する  |  列の移動  |  Toggle 非表示列の表示ステータス  |  範囲と列の比較 ...
注目の機能: グリッドフォーカス   |  デザインビュー   |   ビッグフォーミュラバー    ワークブックとシートマネージャー   |  リソースライブラリ (自動テキスト)   |  日付ピッカー   |  ワークシートを組み合わせる   |  セルの暗号化/復号化    リストごとにメールを送信する   |  スーパーフィルター   |   特殊フィルター (太字/斜体/取り消し線をフィルター...) ...
上位 15 のツールセット12 テキスト ツール (テキストを追加, 文字を削除する、...)   |   50+ チャート 種類 (ガントチャート、...)   |   40+ 実用的 (誕生日に基づいて年齢を計算する、...)   |   19 挿入 ツール (QRコードを挿入, パスから画像を挿入、...)   |   12 変換 ツール (数字から言葉へ, 通貨の換算、...)   |   7 マージ&スプリット ツール (高度な結合行, 分割セル、...)   |   ... もっと

Kutools for Excel で Excel スキルを強化し、これまでにない効率を体験してください。 Kutools for Excelは、生産性を向上させ、時間を節約するための300以上の高度な機能を提供します。  最も必要な機能を入手するにはここをクリックしてください...

説明


Officeタブは、タブ付きのインターフェイスをOfficeにもたらし、作​​業をはるかに簡単にします

  • Word、Excel、PowerPointでタブ付きの編集と読み取りを有効にする、パブリッシャー、アクセス、Visioおよびプロジェクト。
  • 新しいウィンドウではなく、同じウィンドウの新しいタブで複数のドキュメントを開いて作成します。
  • 生産性を 50% 向上させ、毎日何百回もマウス クリックを減らすことができます!
Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
chăng đc gi cả
This comment was minimized by the moderator on the site
As Thuyen pointed out 2 years ago, you can't copy data between sheets while this code is active. Furthermore, the code is needlessly complicated. The sheet that you activate is passed to the procedure as the parameter "Sh". This makes the frequent calls to "ActiveSheet" unnecessary, and could cause problems for someone who's trying to modify the code but isn't very experienced.

Here's my versions that corrects those issues, and even shows how to add a 2nd "Main" sheet (similar to what Dzingai posted):
-----------------------------------------------------------------

'These 2 lines aren't necessary if you use the sheets' codenames, which I recommend.
Set shtMain1 = Worksheets("Main-Sheet-1")
Set shtMain2 = Worksheets("Main-Sheet-2")

If Application.CutCopyMode = False Then
If Sh.Index <> shtMain1.Index And Sh.Index <> shtMain2.Index Then
shtMain1.Move before:=Sh
shtMain2.Move before:=Sh
Sh.Activate
End If
End If
This comment was minimized by the moderator on the site
This code worked well. Only problem is...if we close the file & open it again it goes off.
This comment was minimized by the moderator on the site
[quote]This code worked well. Only problem is...if we close the file & open it again it goes off.By Sangs[/quote] Try saving document as Macro-Enabled Workbook. I think it should work well that way.
This comment was minimized by the moderator on the site
Is it possible to create one with multiple arguments? Like instead of just moving the one main sheet to the front of where you are working, is it possible to move three tabs in front of what you are working on?
This comment was minimized by the moderator on the site
Yes, it is possible, you just have to add more arguments to the if clause using the "AND" like this IF Application.ActiveSheet.Index Application.Sheets("Main-sheet").Index AND Application.ActiveSheet.Index Application.Sheets("Other-Main-sheet").Index and so on... Then Application.Sheets("Main-sheet").Move Before:=Application.Sheets(Application.Sheets("Other-Main-sheet").Index) Application.Sheets("Main-sheet").Activate Application.Sheets("Other-Main-sheet").Move Before:=Application.Sheets(Application.ActiveSheet.Index) Application.Sheets("Other-Main-sheet").Activate Sh.Activate This will place the Main-Sheet, then the Other-Main-Sheet in front of your active sheet.
This comment was minimized by the moderator on the site
is this vba my excel sheet not freezeplease give me solution
This comment was minimized by the moderator on the site
Could not get your code to work, but this one did :) Private Sub Workbook_SheetActivate(ByVal Sh As Object) Dim sc As Long ' count of sheets Dim NewPos As Long ' index of serlected sheet Application.EnableEvents = False Application.ScreenUpdating = False If ActiveSheet.Index 1 Then sc = Sheets.Count NewPos = ActiveSheet.Index For i = 2 To NewPos - 1 Sheets(2).Move After:=Sheets(sc) Next i Sheets(1).Activate Sheets(2).Activate End If Application.ScreenUpdating = True Application.EnableEvents = True End Sub
This comment was minimized by the moderator on the site
When I use VBA, I cannot copy data from Main-Sheet to another sheet Please help me fix this bug
This comment was minimized by the moderator on the site
hahaha. so true! did you find a fix for this?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations