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

ExcelでXNUMX行おきまたはn行目を選択するにはどうすればよいですか?

ワークシートを使用する場合、フォーマット、削除、またはコピーの目的で、シートのXNUMX行おきまたはn行目を選択する必要がある場合があります。 手動で選択できますが、行数が数百の場合、この方法は適切ではありません。 ここにあなたを助けるためのいくつかのトリックがあります。

VBAでXNUMX行おきまたはn行目を選択します

Kutools forExcelでXNUMX行おきまたはn行目を選択します良いアイデア3


VBAでXNUMX行おきまたはn行目を選択します

この例では、XNUMXつの間隔でXNUMXつの行を選択します。 VBAコードを使用すると、次のように終了できます。

1行おきまたはn行目で選択する範囲を強調表示します。

2.Click Developer > ビジュアルベーシック、新しいです アプリケーション用のMicrosoftVisual Basic ウィンドウが表示されたら、をクリックします インセット > モジュール、および次のコードをモジュールに入力します。

Sub EveryOtherRow()
Dim rng As Range
Dim InputRng As Range
Dim OutRng As Range
Dim xInterval As Integer
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
xInterval = Application.InputBox("Enter row interval", xTitleId, Type:=1)
For i = 1 To InputRng.Rows.Count Step xInterval + 1
    Set rng = InputRng.Cells(i, 1)
    If OutRng Is Nothing Then
        Set OutRng = rng
    Else
        Set OutRng = Application.Union(OutRng, rng)
    End If
Next
OutRng.EntireRow.Select
End Sub

3.次にクリックします doc-乗算-計算-3 ボタンを押してコードを実行します。 また、範囲を選択するためのダイアログがポップアップ表示されます。 スクリーンショットを参照してください:



4。 クリック OK、この場合、別のポップアウトダイアログに間隔行として3を入力します。 スクリーンショットを見る

5。 クリック OK、およびXNUMX行ごとに選択されています。 スクリーンショットを参照してください:

あなたは秒で必要に応じて間隔を変更することができます Kutools for Excel ダイアログ。


Kutools forExcelでXNUMX行おきまたはn行目を選択します

VBAコードでは、指定された間隔でXNUMXつの行のみを選択できます。指定された間隔でXNUMXつ、XNUMXつ、またはその他の行を選択する必要がある場合は、 Kutools for Excel この問題を簡単かつ便利に解決するのに役立ちます。

Kutools for Excel, 以上で 300 便利な機能は、あなたの仕事をより簡単にします。 

無料インストール Kutools for Excel、以下のようにしてください:

1。 クリック クツール > Select > Select Interval Rows & Columns…、スクリーンショットを参照してください:

docは8行おきに選択しますXNUMX

2。 の中に  Select Interval Rows & Columns ダイアログボックスをクリックしますdoc-replace-range-names-7 ボタンをクリックして必要な範囲を選択し、 Rows or Columns   Select 、で必要な番号を指定します Interval of 入力ボックスと Rows 入力ボックス。 スクリーンショットを参照してください:

docは9行おきに選択しますXNUMX

docは10行おきに選択しますXNUMX

注意:
1.選択範囲で2行おきに選択する必要がある場合は、[入力の間隔]ボックスに1を入力し、[入力の間隔]ボックスにXNUMXを入力してください。 Rows 入力ボックス。

2.必要な行全体を選択する場合は、次のことを確認できます。 Select entire rows オプションを選択します。
docは11行おきに選択しますXNUMX


Kutools forExcelを使用してXNUMX行おきまたはn行目をシェーディングします

以下のスクリーンショットのようにデータがより目立つように、XNUMX行おきに範囲をシェーディングする場合は、適用できます。 Kutools for Excelさん Alternate Row/Column Shading ジョブをすばやく処理する機能。

docは12行おきに選択しますXNUMX
下向き矢印
docは13行おきに選択しますXNUMX

無料インストール Kutools for Excel、以下のようにしてください:

1.シェーディングの間隔を設定するセルの範囲を選択し、をクリックします クツール > Format > Alternate Row/Column Shading.
docは14行おきに選択しますXNUMX

2。 の中に Alternate Row/Column Shading ダイアログ、次のようにします。

1)シェーディングする行または列を選択します。

2)選択してください Conditional formatting or 標準フォーマット 必要に応じて;

3)シェーディング間隔を指定します。

4)シェーディングカラーを選択します。
docは15行おきに選択しますXNUMX

3。 クリック Ok。 これで、範囲はn行ごとにシェーディングされました。

陰影を削除したい場合は、チェックしてください 既存の代替行シェーディングを削除します 内のオプション 代替の行/列のシェーディング ダイアログ。


関連記事:

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

🤖 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 (12)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Help, please. This looks great, BUT when I hit the > Run button it fails with a "Compile error: Sub or Function not defined" and the code stopped at "Set rng = InputRng.Rows.Count Step xInterval +1".
This comment was minimized by the moderator on the site
Also I don't get how "Set" and "Step" could ever work together
This comment was minimized by the moderator on the site
Not sure that I will be able to help, but.. First of, there is a spacing between "C" and "ount" in "Count" when i copied your code string over to a module. Secondly, I can´t find your code anywhere else on this page, please submit the whole thing, if the problem remains.
This comment was minimized by the moderator on the site
Replace OutRng.EntireRow.Select with Intersect(OutRng.EntireRow, InputRng).Select if you want every other row within your selection
This comment was minimized by the moderator on the site
really good, thanks!
This comment was minimized by the moderator on the site
The code has one request. Does it have to select the ENTIRE ROW for each nth row? Can't it just select certain cells (range of cells) within each nth row? I don't need all the information in each row. Just certain cells of each nth row.
This comment was minimized by the moderator on the site
I made the modifications below to select 30 rows Sub EveryOtherRow() Dim rng As Range Dim InputRng As Range Dim OutRng As Range Dim xInterval As Integer xTitleId = "KutoolsforExcel" Set InputRng = Application.Selection Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8) xInterval = Application.InputBox("Enter row interval", xTitleId, Type:=1) For i = 1 To InputRng.Rows.Count Step xInterval + 1 Set rng = InputRng.Cells(i, 1).Resize(, 30) 'Resize to the number of columns to select, 30 in this case If OutRng Is Nothing Then Set OutRng = rng Else Set OutRng = Application.Union(OutRng, rng) End If Next OutRng.Select 'Use OutRng.EntireRow.Select to select the entire row End Sub
This comment was minimized by the moderator on the site
Nice, thanks, this was very helpful ^_^
This comment was minimized by the moderator on the site
fanatastic. thanks a lot.it works perfect.I have more than 7000 data that need to select them with different interval.this trick was like a miracle for me.thaaaaaaaanks.
This comment was minimized by the moderator on the site
I'm trying to use the VBA macro in Excel 2010. It will only select the first nth row, not all of them in the selection. If I run it again, it will go to the next. Any idea what I'm doing wrong? Thanks!
This comment was minimized by the moderator on the site
Just saved my ass with this code thanks! My matlab decided to randomly stop working and so I had to resort to excel which I am not as familiar with as with Matlab. This def. helped. Thanks.
This comment was minimized by the moderator on the site
I need to select multiple rows and a fixed interval and move to the other sheet please answer me as soon as possible 
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations