Macro to create new sheets based on column

Siddhu11011

Board Regular
Joined
Jun 22, 2022
Messages
56
Office Version
  1. 365
Platform
  1. Windows
I have numbers or text in column A and want to create new sheets based on cells available in that column. New sheets name must be unique (unique values from column A).
Bring the number of rows along with header for that particular cell without removing duplicates in respective sheet. Please see below snapshots

Thanks for reading my query and would be happy if you can help....
Note: Table size is not constant; columns and rows get changing all the time



1673808176223.png

1673808211252.png

1673808227292.png

1673808242104.png
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi.
For the example you've posted try the code below. The number of rows with data can vary, and the code will detect it, but about the variation of the number of columns with data we need to see some relevant examples.

VBA Code:
Sub NewSheets()
 Dim evnt As Long, k As Long
  Application.ScreenUpdating = False
  With Sheets("Data")
   For evnt = 2 To .Cells(Rows.Count, 1).End(3).Row
    k = Application.CountIf(.[A:A], .Cells(evnt, 1))
     Sheets.Add(, Sheets(Sheets.Count)).Name = .Cells(evnt, 1)
     [A1].Resize(, 3) = Array("Event", "Account", "Qty")
     [A2].Resize(k, 3) = .Cells(evnt, 1).Resize(k, 3).Value
     evnt = evnt + k - 1
   Next evnt
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,094
Latest member
bsb1122

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top