Pull data from several column's to a new page if column a matches set criteria

benmoore89

New Member
Joined
Oct 27, 2015
Messages
11
Hi there,

I have got a table with over 20 columns and hundreds of rows of data. hear is a small sample

TMNameDatePostedUserUser IDPCROleDTDestinationSKDestinationBSDestinationRepRoleRepNameCI1CI2CI3CI4CI5CI6CI7CBCI1CBCI2CBCSQ3CBComplaint4CBSales5Percentage %
Marta08/01/2015 17:03sz.marta87172Head Rep DomRep&JamaicaPUJ RepKatarzyna555555555103015100%
Hamid 08/02/2015 10:53hamidwin#N/ATM KOSKGS RepAndre555555555103015100%
Stefan08/02/2015 15:36stefan.minimayr164TMLanzaroteACE RepSander5555555550301590%
Felicity08/03/2015 12:26felicitysparkle40TMIbiza RepKelsey555555555103015100%
Felicity08/03/2015 12:29felicitysparkle40TMIbiza RepNatalie55555055510301595%
Joanne08/03/2015 16:22joandjar67TM MexicoCUN RepGillian55550055510301590%
Joanne 08/03/2015 16:25joandjar67TM MexicoCUN RepEmily555555555103015100%
Jackie 08/04/2015 12:36wroey76195TMFuerteventuraFUE RepChloe55555005510301590%
Jackie 08/04/2015 12:36wroey76195TMFuerteventuraFUE RepChloe555555555103015100%

<colgroup><col><col><col><col><col><col><col><col><col><col><col span="12"><col></colgroup><tbody>
</tbody>

Column A consists of the users name, this is what i want to use as my criteria. So if column a had the name 'Felicity' i want to pull all the rows matching that name in column 1 into a separate sheet called 'felicity' along with the data in the other 20 or so columns

If you need me to elaborate more then i can

Thanks in advance
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi benmoore89,

Have done a little code for you.

Put the following code in the sheet that contains the original table

Then right click any value in column A and a new sheet will be created as requested.

Enjoy

ExcelGringe




Option Explicit


Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Dim strName As String
Dim lngMaxRow As Long
Dim lngMaxCol As Long
Dim i As Long
Dim a As Long
Dim ii As Long
Dim wsT As Excel.Worksheet
Dim wsC As Excel.Worksheet

If Target.Column = "1" And Target.Row > 1 Then
strName = Target.Value
lngMaxRow = ActiveSheet.Range("A65536").End(xlUp).Row
lngMaxCol = ActiveSheet.Range("IX1").End(xlToLeft).Column


Application.DisplayAlerts = False
On Error Resume Next
Worksheets(strName).Delete
On Error GoTo 0
Application.DisplayAlerts = True
Set wsC = ActiveWorkbook.ActiveSheet
Set wsT = Worksheets.Add(After:=ActiveSheet)
wsT.Name = strName
ii = 1

For i = 1 To lngMaxRow
If i = 1 Or strName = wsC.Range("A" & i).Value Then
For a = 1 To lngMaxCol
wsT.Cells(ii, a).Value = wsC.Cells(i, a).Value
Next a
ii = ii + 1
End If
Next i

wsT.Cells.EntireColumn.AutoFit

Cancel = True
End If
End Sub
 
Upvote 0
wow that's some formula thanks, only prob i have now is when i copy and paste it into excel it just displays as text on the page and does not hide as a formula and when i right click there is no option to send data to another page. im not very excel literate (knowledge limited to sum's countif and subtotal) is there a spesific way im supposed to enter the formula above ???

Thanks again :)
 
Upvote 0
Hi benmoore89,

The code I gave you is vba and should be placed in the sheets VBA code section

First of all make sure you save your file as .xlsm. (To keep macros)

Then with the worksheet open right click the sheet name (at the bottom) then click (View Code).

Now insert the code (make sure you only have one option explicit at the beginning)

Now press save and then the X in the top right hand corner.

Now right click in column A (Other than Row 1) and you should see the result you want. Another sheet with data will be created with a name of the Person and the data for that person.

THIS IS VBA CODE NOT A FORMULA.

If you need further help just ask.

Regards

ExcelGringe
 
Upvote 0
I would suggest using Pivot Table using the Page (Filter) field and the Pivot Table Option: Show Report Filter Pages.
Since the Pivot Table is a report based on (and linked to) the original data, it is not duplicated data.
The Pivot Table Option: Show Report Filter Pages, creates an additional tab for each filter value with that filter values name if useable as a sheet name.
This accomplishes the same goal as the above VBA without VBA.
The Pivot Table would be with all fields, no subtotals or grand totals and in Tabular form.

I would also examine the TABLE method with Slicers to avoid the multiple sheets all together. (Version 2013, see https://support.office.com/en-us/article/Filter-data-in-an-Excel-table-7D8E9739-2898-4BFE-9D0F-C6204E6E5C8A
 
Upvote 0

Forum statistics

Threads
1,216,732
Messages
6,132,409
Members
449,726
Latest member
Skittlebeanz

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