grouping of data

Manexcel

Board Regular
Joined
Dec 28, 2015
Messages
128
Office Version
  1. 365
Platform
  1. Windows
I am using MsExcel 2016.

On sheet test11 I have a list of (12000+ rows). Headed by Name and Grade and date. Data starts in A2

On sheet sheet2 I wish to group that data by say; name.

test 1 example data (the name field does have the surname, first name middle name all in one column)

Name Grade Date
Smith, John charles, Grade 3, 01-jan-18
Smith, John charles, Grade 2, 01-jan-17
Smith, John charles, Grade 1, 01-jan-16
jones, fred bloggs, Grade 1, 01-jan-18
smith, jack, grade 1,01-jan-16
smith, jack, grade 2,01-feb-18

etc
to row 12000+

On sheet 2

I wish to display / group that data by say name. As I could have many rows with same surname names, but different first and middle names, each with different grades and dates I wish to end up with all the data
being grouped as below.

Name Grade Date
Smith, John charles Grade 3 01-jan-18
Grade 2 01-jan-17
Grade 1 01-jan-16
jones, fred bloggs Grade 1 01-jan-18
smith, jack Grade 1 01-jan-16
Grade 2 01-feb-18
Etc.

The VBA script that was very kindly provided before is below;



Code:
Sub SplitData()

    Dim SrcSht As Worksheet
    Dim DestSht As Worksheet
    Dim UsdRws As Long
    Dim Cl As Range
    
Application.ScreenUpdating = False

    Set SrcSht = ThisWorkbook.Sheets("test1")
    Set DestSht = ThisWorkbook.Sheets("Sheet2")
    UsdRws = SrcSht.Range("B" & Rows.Count).End(xlUp).Row
    With CreateObject("scripting.dictionary")
        For Each Cl In SrcSht.Range("B2:B" & UsdRws)
            If Not .Exists(Cl.Value) Then
                .Add Cl.Value, Nothing
                SrcSht.Range("A1").AutoFilter 2, Cl.Value
                If .Count = 1 Then
                    DestSht.Range("A1") = Cl.Value
                    DestSht.Range("A1").Font.Bold = True
                    SrcSht.Range("C1:C" & UsdRws).SpecialCells(xlVisible).copy DestSht.Range("A" & Rows.Count).End(xlUp).Offset(2, 1)
                    SrcSht.Range("A1:A" & UsdRws).SpecialCells(xlVisible).copy DestSht.Range("A" & Rows.Count).End(xlUp).Offset(2)
                Else
                    DestSht.Range("A" & Rows.Count).End(xlUp).Offset(3) = Cl.Value
                    DestSht.Range("A" & Rows.Count).End(xlUp).Font.Bold = True
                    SrcSht.Range("C2:C" & UsdRws).SpecialCells(xlVisible).copy DestSht.Range("A" & Rows.Count).End(xlUp).Offset(2, 1)
                    SrcSht.Range("A2:A" & UsdRws).SpecialCells(xlVisible).copy DestSht.Range("A" & Rows.Count).End(xlUp).Offset(2)
                End If
            End If
        Next Cl
I thank you for your assistance.
 
Last edited by a moderator:
This proving challenging to achieve. When running the procedure I am now getting the following message box.

runtime error 1004
application defined or
object defined in error

with the option of OK or Help buttons

I need to click either Ok or help buttons, otherwise I cannot move to the debug option as you suggested

For further information which may assist. My dataset is 12k+ rows. The procedure runs and creates the output on the destination sheet. I know it goes to the end of the dataset because the names beginning with "Z" appearing on the destination sheet

Is there an option to run automatically the procedure BUT in debug mode which will give you the C1 value?

Does the above assist? Thanks again.
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Not sure what's going wrong & I can't replicate your errors.
Are either of your sheets protected?
Do you have any merged cells?
 
Upvote 0
The sheets are not protected and there are no merged cells. However, over the weekend I performed some additional testing. I have reduced the number lines of data to process down to around 9000, and to date all appears to work ok. I dont get the error messages as previously described.

So once again I thank you so much for all your assistance and patience.
 
Upvote 0
Glad to help & sorry I couldn't fully resolve the problem
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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