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

Excelで特定のテキストの上に空白行を挿入するにはどうすればよいですか?

doc特定のテキストの上に行を挿入1 2 doc特定のテキストの上に行を挿入2

ワークシートで作業しているときに、列の特定のテキストの上に空白行を挿入しようとしたことがありますか? たとえば、列Aにいくつかの名前がありますが、左のスクリーンショットに示すように、「マイク」という名前を含むセルの上に空白行を挿入したいのですが、Excelでこのタスクを直接解決する方法がない可能性があります。 。 この記事では、Excelでこのジョブを処理するためのいくつかの良いトリックについて説明します。

VBAコードを使用して特定のテキストの上に空白行を挿入します

Kutools for Excelを使用して、特定のテキストの上に空白行を挿入します


VBAコードを使用して特定のテキストの上に空白行を挿入します

特定のテキストの上に空白行をXNUMXつずつ手動で挿入すると、多くの時間が無駄になります。ここでは、特定のセル値の上に空白行を一度に挿入するためのVBAコードを作成します。

1。 を押し続けます Alt + F11 キー、そしてそれは開きます アプリケーション向け Microsoft Visual Basic 窓。

2に設定します。 OK をクリックします。 インセット > モジュール、次に次のマクロをに貼り付けます モジュール 窓。

VBAコード:特定のテキストの上に空白行をすばやく挿入する

Sub test1()
'updateby Extendoffice
    Dim i As Long
    Dim xLast As Long
    Dim xRng As Range
    Dim xTxt As String
    On Error Resume Next
    xTxt = Application.ActiveWindow.RangeSelection.Address
    Set xRng = Application.InputBox("please select the column with specific text:", "Kutools for Excel", xTxt, , , , , 8)
    If xRng Is Nothing Then Exit Sub
    If (xRng.Columns.Count > 1) Then
        MsgBox "the selected range must be one column", , "Kutools for Excel"
        Exit Sub
    End If
    xLast = xRng.Rows.Count
    For i = xLast To 1 Step -1
      If InStr(1, xRng.Cells(i, 1).Value, "Mike") > 0 Then
        Rows(xRng.Cells(i, 1).Row).Insert shift:=xlDown
      End If
    Next
End Sub

3。 次に、 F5 このコードを実行するためのキーを押すと、ダイアログボックスが表示され、上に行を挿入する特定のテキストを含む列データを選択するように通知されます。スクリーンショットを参照してください。

doc特定のテキストの上に行を挿入3

4。 そして、 OK ボタンをクリックすると、特定のテキスト「マイク」の上に空白行が挿入されます。

Note:上記のコードでは、テキスト値を変更できます。マイク」をスクリプトから必要な他の値に変更します InStr(1、xRng.Cells(i、1).Value、 "Mike")> 0の場合 その後.


Kutools for Excelを使用して、特定のテキストの上に空白行を挿入します

あなたが持っている場合 Kutools for Excelそのと 特定のセルを選択 この機能では、最初に指定したセル値を選択してから、Excelの[シート行の挿入]ユーティリティを適用して、空白行を一度に挿入できます。

Kutools for Excel : 300以上の便利なExcelアドインがあり、30日以内に制限なしで無料で試すことができます

インストールした後 Kutools for Excel、次のようにしてください。

1。 使用するデータ範囲を選択します。

2。 次に、をクリックします クツール > 選択 > 特定のセルを選択、スクリーンショットを参照してください:

3。 の中に 特定のセルを選択 ダイアログボックスで セル選択タイプ、次に必要な基準を指定します 特定のタイプ セクション、この場合、私は選択します 等しいです 特定のタイプ、選択したい名前を入力します。スクリーンショットを参照してください。

doc特定のテキストの上に行を挿入5

4。 次に、をクリックします Ok ボタンをクリックすると、値がMikeであるすべてのセルが一度に選択されます。スクリーンショットを参照してください。

doc特定のテキストの上に行を挿入6

5. 特定のテキストセルを選択したら、をクリックしてください ホーム > インセット > シート行を挿入、および空白行が選択したテキストの上に挿入されます。スクリーンショットを参照してください。

doc特定のテキストの上に行を挿入7 2 doc特定のテキストの上に行を挿入2

 今すぐExcel用のKutoolsをダウンロードして無料トライアル!


デモ:Kutools for Excelを使用して、特定のテキストの上に空白行を挿入します

Kutools for Excel:300以上の便利なExcelアドインがあり、30日以内に制限なしで無料で試すことができます。 今すぐダウンロードして無料トライアル!

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

🤖 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 (7)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I try do it to put a blank row after every non-empty cell, but excel says. "That command cannot be used on multiple selections"
Why it dosnt work for me???
This comment was minimized by the moderator on the site
Is there a way not to appears dialog box with pop out to remind me to select the column data which contains specific text I want to insert row above, If a specified cell is filled with data, then process run automatically , without promptings, and insert row above?
This comment was minimized by the moderator on the site
This has been amazing for the data I have. I was wondering if you could help me one step further. I have been able to split my data based on this, but then I need to colour code my groups of data. When I split my data I have a variable number of rows from 1-50, and I have 36 columns of data including 32 columns that I need to compare the values within to the top row. I am currently manually selecting each group (as separated by a blank row) and then using ctrl+shift+| to highlight column differences, and formatting those cells to highlight the differences.


Is there anyone who could write a code to select and format those column differences within the groupings, using the blank row as a separator?
This comment was minimized by the moderator on the site
Hi, i have a similar problem as the one above. What if i want to select the cell below a specified criteria? For example, you can use the example from above. i want to select the cell below "Mike". is there any easy way out?
This comment was minimized by the moderator on the site
@SSJ did you ever find a solution?
This comment was minimized by the moderator on the site
Hello, guys,

To insert blank rows below a specific cell value, you can apply the following code:

Sub BlankLine()
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Set WorkRng = WorkRng.Columns(1)
xLastRow = WorkRng.Rows.Count
Application.ScreenUpdating = False
For xRowIndex = xLastRow To 1 Step -1
Set Rng = WorkRng.Range("A" & xRowIndex)
If Rng.Value = "Mike" Then
Rng.Offset(1, 0).EntireRow.Insert Shift:=xlDown
End If
Next
Application.ScreenUpdating = True
End Sub

Please change the criteria "Mike" to your own cell value.

Hope it can help you, thank you!
This comment was minimized by the moderator on the site
thank you! its worked.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations