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

Excelで長いリストを等しいグループに分割するにはどうすればよいですか?

グループへのドキュメント分割リスト4

次のスクリーンショットのように、複数の等しいグループに分割する必要のあるデータの長いリストがある場合、Excelでこのタスクをすばやく簡単に処理するにはどうすればよいですか?

長いリストをVBAコードで複数の等しいグループに分割する

Kutools for Excelを使用して、長いリストを複数の等しいグループに分割します


データをXNUMXつずつコピーして貼り付けることを除いて、次のVBAコードも役立ちます。次の手順で実行してください。

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

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

VBAコード:長いリストを複数の等しいグループに分割する

Sub SplitIntoCellsPerColumn()
'updateby Extendoffice
    Dim xRg As Range
    Dim xOutRg As Range
    Dim xCell As Range
    Dim xTxt As String
    Dim xOutArr As Variant
    Dim I As Long, K As Long
    On Error Resume Next
    xTxt = ActiveWindow.RangeSelection.Address
Sel:
    Set xRg = Nothing
    Set xRg = Application.InputBox("please select data range:", "Kutools for Excel", xTxt, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    If xRg.Areas.Count > 1 Then
        MsgBox "does not support multiple selections, please select again", vbInformation, "Kutools for Excel"
        GoTo Sel
    End If
    If xRg.Columns.Count > 1 Then
        MsgBox "does not support multiple columns,please select again", vbInformation, "Kutools for Excel"
        GoTo Sel
    End If
    Set xOutRg = Application.InputBox("please select a cell to put the result:", "Kutools for Excel", , , , , , 8)
    If xOutRg Is Nothing Then Exit Sub
    I = Application.InputBox("the number of cell per column:", "Kutools for Excel", , , , , , 1)
    If I < 1 Then
        MsgBox "incorrect enter", vbInformation, "Kutools for Excel"
        Exit Sub
    End If
    ReDim xOutArr(1 To I, 1 To Int(xRg.Rows.Count / I) + 1)
    For K = 0 To xRg.Rows.Count - 1
      xOutArr(1 + (K Mod I), 1 + Int(K / I)) = xRg.Cells(K + 1)
    Next
    xOutRg.Range("A1").Resize(I, UBound(xOutArr, 2)) = xOutArr
End Sub

3. 次に、 F5 このコードを実行するにはキーを押し、ポップアウトされたボックスで、複数のグループに分割する列を選択してください。スクリーンショットを参照してください。

グループへのドキュメント分割リスト1

4。 をクリックします OK ボタンをクリックし、次のプロンプトボックスで結果を検索するセルを選択します。スクリーンショットを参照してください。

グループへのドキュメント分割リスト2

5に設定します。 OK をクリックします。 OK、およびプロンプトボックスに列ごとに分割するセルの数を入力してください。スクリーンショットを参照してください。

グループへのドキュメント分割リスト3

6。 最後に、 OK コードを完成させるには、選択したリストデータが必要に応じて複数の等しいグループに分割されています。スクリーンショットを参照してください。

グループへのドキュメント分割リスト4


あなたがインストールしている場合 Kutools for Excelそのと 変換範囲 この機能では、長いリストを複数の列と行にすばやく分割できます。さらに、複数の列をXNUMXつの長いリストに結合することもできます。

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

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

1。 分割する長いリストを選択し、をクリックします クツール > レンジ > 変換範囲、スクリーンショットを参照してください:

2。 の中に 変換範囲 ダイアログボックスで 範囲に単一の列変換タイプ セクション、そしてチェック 固定値 ボックスの行ごとのセル数を指定します。スクリーンショットを参照してください。

グループへのドキュメント分割リスト7

3。 次に、をクリックします Ok、プロンプトボックスで結果を検索するセルを選択します。スクリーンショットを参照してください。

グループへのドキュメント分割リスト8

4. クリック OK ボタンをクリックすると、リスト内のデータが必要に応じて複数の等しいグループに分割されます。

今すぐ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 (8)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
the code works great for me. How do I change it from asking how many in each colum to how many columns needed? so that it equally divides the information into a set number of columns.
This comment was minimized by the moderator on the site
Hello, trinetta,
May be the following article can help you, in that article, there are some formulas may meet your need. Please check it:
https://www.extendoffice.com/documents/excel/681-excel-change-columns-to-rows.html
This comment was minimized by the moderator on the site
The link only tells me how to do the same thing. It doesnt tell me how to tell the code or formula how many columns i need...just how many in each column.
This comment was minimized by the moderator on the site
Hi, Tpdixon,
In that article, the formula: =OFFSET($A$1,COLUMNS($A1:A1)-1+(ROWS($1:1)-1)*5 can help you to split the list into mulitiple columns, you just need to change the number 5 to other number you need, it represents the column number.
After entering this formula, you should drag the fill handle acrross to right with 5 cells.
Please try, thank you!
This comment was minimized by the moderator on the site
how can I change it from the number of cells per column to the number of columns needed. so that the data is split up evenly amongst a number of columns instead of picking how many to have in each column?
This comment was minimized by the moderator on the site
I copied the code and Excel 365 says syntax error.
This comment was minimized by the moderator on the site
This comes in very handy! One question: In the VBA code how can I transpose the output? So instead of xRg.Rows.Count / I = number of colums output, the output is generated as xRg.Rows.Count / I = number of rows output with I being the number of columns per row.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations