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

Excelで行ごとに新しいシートを作成するにはどうすればよいですか?

列Aにすべての学生の名前が含まれるスコアテーブルがあるとします。次に、列Aのこれらの名前に基づいて新しいシートを作成し、シートごとに一意の学生のデータが含まれているとします。 または、列Aの名前を考慮せずに、テーブルの各行に対して新しいシートを作成するだけです。このビデオでは、それを実現するためのメソッドを取得します。

VBAコードを使用して行ごとに新しいシートを作成します
Kutools forExcelのSplitDataユーティリティを使用して、行ごとに新しいシートを作成します


VBAコードを使用して行ごとに新しいシートを作成します

次のコードを使用すると、列の値に基づいて新しいシートを作成することも、Excelの各行に新しいシートを作成することもできます。

1。 押す 他の + F11 キーを同時に開いて アプリケーション向け Microsoft Visual Basic 窓。

2。 の中に アプリケーション向け Microsoft Visual Basic ウィンドウ、クリック インセット > モジュール。 次に、次のコードをに貼り付けます モジュール 窓。

VBAコード:列に基づいて行ごとに新しいシートを作成します

Sub parse_data()
'Update by Extendoffice 2018/3/2
    Dim xRCount As Long
    Dim xSht As Worksheet
    Dim xNSht As Worksheet
    Dim I As Long
    Dim xTRrow As Integer
    Dim xCol As New Collection
    Dim xTitle As String
    Dim xSUpdate As Boolean
    Set xSht = ActiveSheet
    On Error Resume Next
    xRCount = xSht.Cells(xSht.Rows.Count, 1).End(xlUp).Row
    xTitle = "A1:C1"
    xTRrow = xSht.Range(xTitle).Cells(1).Row
    For I = 2 To xRCount
        Call xCol.Add(xSht.Cells(I, 1).Text, xSht.Cells(I, 1).Text)
    Next
    xSUpdate = Application.ScreenUpdating
    Application.ScreenUpdating = False
    For I = 1 To xCol.Count
        Call xSht.Range(xTitle).AutoFilter(1, CStr(xCol.Item(I)))
        Set xNSht = Nothing
        Set xNSht = Worksheets(CStr(xCol.Item(I)))
        If xNSht Is Nothing Then
            Set xNSht = Worksheets.Add(, Sheets(Sheets.Count))
            xNSht.Name = CStr(xCol.Item(I))
        Else
            xNSht.Move , Sheets(Sheets.Count)
        End If
        xSht.Range("A" & xTRrow & ":A" & xRCount).EntireRow.Copy xNSht.Range("A1")
        xNSht.Columns.AutoFit
    Next
    xSht.AutoFilterMode = False
    xSht.Activate
    Application.ScreenUpdating = xSUpdate
End Sub

Note:A1:C1はテーブルのタイトル範囲です。 必要に応じて変更できます。

3。 押す F5 コードを実行するためのキーを押すと、以下のスクリーンショットのように、現在のワークブックのすべてのワークシートの後に新しいワークシートが作成されます。

列の値を考慮せずに行ごとに新しいシートを直接作成する場合は、次のコードを使用できます。

VBAコード:行ごとに新しいシートを直接作成します

Sub RowToSheet()
	Dim xRow As Long
	Dim I As Long
	With ActiveSheet
		xRow = .Range("A" & Rows.Count).End(xlUp).Row
		For I = 1 To xRow
			Worksheets.Add(, Sheets(Sheets.Count)).Name = "Row " & I
			.Rows(I).Copy Sheets("Row " & I).Range("A1")
		Next I
	End With
End Sub

コードを実行すると、アクティブなワークシートの各行が新しいワークシートに配置されます。

Note:見出し行も、このVBAコードを使用して新しいシートに配置されます。


Kutools forExcelのSplitDataユーティリティを使用して、行ごとに新しいシートを作成します

実際、上記の方法は複雑で理解しにくいものです。 このセクションでは、 分割データ の有用性 Kutools for Excel.

申請する前に Kutools for Excelについては 最初にダウンロードしてインストールします.

1.新しいシートの作成に使用する必要のあるテーブルを選択し、[ クツールズプラス> スピットデータ。 スクリーンショットを参照してください:

2。 の中に データを複数のワークシートに分割する ダイアログボックスは、次のようにしてください。

A.列の値に基づいて新しいシートを作成するには:

1)。 を選択してください 特定の列 オプションを選択し、ドロップダウンリストでデータを分割する列を指定します。
2)。 ワークシートに列の値で名前を付ける場合は、を選択してください 列の値 セクションに キャンペーンのルール ドロップダウンリスト;
3)。 クリック OK ボタン。 スクリーンショットを参照してください:

B.各行に新しいシートを直接作成する場合:

1)。 選択する 固定行 オプション、番号を入力 1 ボックスに;
2)。 選択する 行番号 キャンペーンのルール ドロップダウンリスト;
3)。 クリック OK ボタン。 スクリーンショットを参照してください:

すべての新しいシートが入った新しいワークブックが作成されます。 以下のスクリーンショットを参照してください。

列の値に基づいて各行に新しいシートを作成します。

列の値を考慮せずに各行に新しいシートを作成する:

  このユーティリティの無料トライアル(30日)が必要な場合は、 クリックしてダウンロードしてください、次に、上記の手順に従って操作を適用します。

Kutools forExcelのSplitDataユーティリティを使用して、行ごとに新しいシートを作成します

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

🤖 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 (33)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
HI, Thanks for this wonder-full code, Can we get dynamic sheet, means if i update data in respective sheet it will get updated in main sheet.
This comment was minimized by the moderator on the site
Hi vikas chandra,
I can't fix this problem. Sorry about that.
This comment was minimized by the moderator on the site
Hi, I have a problem about title, the title range of my table is A1:AI2, when I changed the code like that it doesn't work.

***Note: A1:C1 is the title range of your table. You can change it based on your needs.***
This comment was minimized by the moderator on the site
Hello, thanks so much for this. I'm looking to modify the macro such that it will create a sheet for each row of a column and within each sheet have a function (average) that I can populate data into and in turn have the outcome linked back into the original sheet. Is this possible? I can try to clarify further if this doesn't make sense or is ambiguous.
This comment was minimized by the moderator on the site
Hi, is there a code which would add only 1 new sheet each time the macro is run, eg 1st time the new sheet would be named on the contents of cell A1, 2nd time the macro was run the new sheet would be named on the contents of A2 etc. thanks in anticipation
This comment was minimized by the moderator on the site
Hello, used this code and worked, but If I want select the more then one rows in header, what will be change in the code ? I have multiple lines in the sheet which I want in every sheet.
This comment was minimized by the moderator on the site
Hello, did you figured out how?
This comment was minimized by the moderator on the site
Hello! I just used this code and it worked! In addition to creating a new sheet for each entry, I want to transpose it to columns and can't figure it out. So for the above example, the output for Nana would look like this - Name NanaScore 86No. 2
This comment was minimized by the moderator on the site
<p> Nana
86
2</p>
This comment was minimized by the moderator on the site
How to reference the use of the code above (credit) ? Is it possible to modify the code ?
This comment was minimized by the moderator on the site
Hi, this is an open communication platform. The code is allowed to reference and modify.
This comment was minimized by the moderator on the site
Nevermind it was hidden trailing spaces. I used the TRIM feature and cleaned it up. Having a row count (line count really so rows -1 prepended to the sheet would be amazing)
This comment was minimized by the moderator on the site
Please can i get help on how to automatically name the sheets using a particular column. This is for the row to sheet VBA. See below

Sub RowToSheet()

Dim xRow As Long

Dim I As Long

With ActiveSheet

xRow = .Range("A" & Rows.Count).End(xlUp).Row

For I = 1 To xRow

Worksheets.Add(, Sheets(Sheets.Count)).Name = "Row " & I

.Rows(I).Copy Sheets("Row " & I).Range("A1")

Next I

End With

End Sub
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations