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

Excelでセルを連結して空白を無視またはスキップするにはどうすればよいですか?

Excelの 連結する この関数は、複数のセル値をXNUMXつのセルにすばやく結合するのに役立ちます。選択したセル内に空白のセルがある場合、この関数は空白も結合します。 しかし、セルをデータと連結して空のセルをスキップしたい場合は、Excelでどのように終了できますか?

セルを連結すると、数式で空白が無視またはスキップされます

連結セルは、ユーザー定義関数を使用して空白を無視またはスキップします

連結セルは、Kutools forExcelで空白を無視またはスキップします


いくつかの空白セルが入力された次のセルデータがあるとすると、行をXNUMXつのセルに結合するために、数式を適用してそれを解決できます。

ドキュメントはスキップブランクを組み合わせる1

連結した結果を入力する空白のセルにこの数式を入力してください。 =A1&IF(A2<>"","-"&A2,"")&IF(A3<>"","-"&A3,"")&IF(A4<>"","-"&A4,"")&IF(A5<>"","-"&A5,"")、次に、この数式を適用するセルに塗りつぶしハンドルを右にドラッグすると、次のスクリーンショットに示すように、行の値が空白のセルなしで結合されます。

ドキュメントはスキップブランクを組み合わせる2

ヒント:連結する必要のある行がさらにある場合は、IF関数を使用してセルを結合する必要があります。 =A1&IF(A2<>"","-"&A2,"")&IF(A3<>"","-"&A3,"")&IF(A4<>"","-"&A4,"")&IF(A5<>"","-"&A5,"")&IF(A6<>"","-"&A6,"")。 "" 数式の文字は、必要な他の区切り文字に置き換えることができます。


複数のセルを連結すると、空白が無視またはスキップされます。

Kutools for Excel's 組み合わせる データを失うことのない行、列、またはセル この機能は、データを失うことなく複数の行、列、またはセルを結合または連結するのに役立ちますが、空白のセルをスキップまたは無視します。 クリックしてKutoolsfor Excelをダウンロードしてください!

ドキュメントはスキップブランクを組み合わせる7

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


組み合わせる必要のあるセルが複数ある場合、上記の数式は複雑すぎて実行できないため、次のユーザー定義関数を使用して解決できます。

1。 を押し続けます Altキー+ F11 Excelでキーを押すと、 アプリケーション向け Microsoft Visual Basic 窓。

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

VBAコード:連結セルは空白を無視します:

Function Concatenatecells(ConcatArea As Range) As String
'updateby Extendoffice
  For Each n In ConcatArea: nn = IIf(n = "", nn & "", nn & n & "/"): Next
  Concatenatecells = Left(nn, Len(nn) - 1)
End Function

3。 このコードウィンドウを保存して閉じ、ワークシートに戻って、次の数式を入力します。 = concatenatecells(A1:A5) 空白のセルに入力し、塗りつぶしハンドルをセルに右にドラッグしてこの数式を適用すると、次の結果が得られます。

ドキュメントはスキップブランクを組み合わせる3

ヒント:上記のVBAコードでは、「/」文字を必要な他の区切り文字に変換します。


退屈な式とコードを除いて、ここでは、便利なツールをお勧めします-Kutools for Excel、その強力な 組み合わせる ユーティリティを使用すると、手間をかけずに複数のセルをXNUMXつのセルに連結できます。

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

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

1。 組み合わせるセルの値を選択します。

2に設定します。 OK をクリックします。 クツール > マージ&スプリットデータを失うことなく行、列、またはセルを組み合わせる、スクリーンショットを参照してください:

3。 ポップアウトされたダイアログで:

  • (1.)結合するセルのタイプを選択します。列を結合し、行を結合し、すべてのセルをXNUMXつのセルに結合できます。
  • (2.)連結されたコンテンツの区切り文字を指定します。
  • (3.)結果を配置する場所を選択します。結果を上部のセルまたは下部のセルに配置できます。
  • (4.)結合されたセルの処理方法を指定し、それらの結合されたセルの内容を保持または削除したり、それらの結合されたセルをマージしたりすることもできます。

ドキュメントはスキップブランクを組み合わせる5

4。 設定が終わったら、 Ok ボタンをクリックすると、選択した行がXNUMXつのセルに個別に結合され、空白が自動的にスキップされます。スクリーンショットを参照してください。

ドキュメントはスキップブランクを組み合わせる6

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


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 (14)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
How would you change the "/" sign for CHAR(10) or line break?
This comment was minimized by the moderator on the site
Hello, Alan,To combine the cells with the line break, you can apply the below simple formula:=TEXTJOIN(CHAR(10),TRUE,A1:A5)
After getting the results with this formula, you should click the Wrap Text to get the correct results you need.
Please try, thank you!
This comment was minimized by the moderator on the site
super, thank Q
This comment was minimized by the moderator on the site
I had issues with the formula provided causing leading delimiters, so I did this instead and it works well. This is concatenating cells horizontally while ignoring blank cells and results in no extra commas.

=IF(A2="", "", A2)&IF(A2="", "", ", ")&IF(B2="", "", B2)&IF(B2="", "", ", ")&IF(C2="", "", C2)
This comment was minimized by the moderator on the site
This worked a treat, thanks so much
This comment was minimized by the moderator on the site
Hi, used the macro and changed the "/" to a comma "," but got a lot of commas and it appeared to add all the blank cells.
I am doing a nested if statement to determine the appropriate sorting in the database. Is this enough to make the blank cell 'active' so that the macro sees this and adds it to the text string? How to work around that?
thanks much
This comment was minimized by the moderator on the site
Hello, Melinda,
the above vba code works well in my worksheet, you just need to change the separator / to comma as below:

Function Concatenatecells(ConcatArea As Range) As String
'updateby Extendoffice 20151103
For Each n In ConcatArea: nn = IIf(n = "", nn & "", nn & n & ","): Next
Concatenatecells = Left(nn, Len(nn) - 1)
End Function

and then apply this formula:=concatenatecells(A1:A5)
This comment was minimized by the moderator on the site
thanks!
I found my problem was in the logic statement that I used to select data for these cells that I was trying to text string. I used a " " instead of "" for the false statement. That was picked up by the macro and used as a space bar and came out , , , , , text, , , ,
So I went back and took out the space and just have the "" and then the macro worked great.
Of course I am learning macros so that's another adventure.
thanks much!!
This comment was minimized by the moderator on the site
Thank you, it was very helpful!
This comment was minimized by the moderator on the site
Please help, i dont always have a value in my first column, that couses that I end up with a seperator infort of the final result. Is there a way around this?
This comment was minimized by the moderator on the site
ever get tis figured out? same boat.
This comment was minimized by the moderator on the site
I don't know how to do it all in one cell, but I added a row with this formula: =IF(LEFT(U20,1)=",",RIGHT(U20,LEN(U20)-2),U20).
My separator was a comma and a space ", " so I used -2 for LEN. U20 is the cell with the concatenated &if formula. The logic of this formula is that if the first character from the left equals a comma, then delete the first two characters; otherwise leave it alone.

Hope this helps.
This comment was minimized by the moderator on the site
Thank you! This saved hours of frustration on my part! Works as a charm!
This comment was minimized by the moderator on the site
The VBA script is wrong, because the output of the formula puts a huge space between the delimiters.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations