Extraction of Data based on dynamic criteria

thespardian

Board Regular
Joined
Aug 31, 2012
Messages
119
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
Q1.png


I simply want a dynamic way to group the above data . if there is empty cell in the column J (Centre) then ignore the whole row otherwise extract the data groups as per below format.


Q2.png


Any help will be highly appreciated.
Here is the link for excel file
Question123.xlsx
 
I clicked the button and I don't see anything wrong on the Result sheet. What was not correct? I probably missed something.
Using button, It fetch only 2 line for Centre ABC and zero line for DEF whereas the correct results are 10 line for ABC and three line for DEF. If you run the code by clicking Developer > Visual Basic> Module1 and hit the play button. You'll see the difference.
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Using button, It fetch only 2 line for Centre ABC and zero line for DEF whereas the correct results are 10 line for ABC and three line for DEF. If you run the code by clicking Developer > Visual Basic> Module1 and hit the play button. You'll see the difference.
This is what I get when I clicked

Zot.xlsm
ABCDEFGHI
5Sr. DateCashier Bill #Customer NameProduct CodeAmountTaxNet
6ABC
718544195By Letter10088Jhon SmithVI-550500D
818544195By Letter10088Jhon SmithB011520967D
918544195By Letter10088Jhon SmithC016430300D
1018544195By Letter10088Jhon SmithC016110150D
1118544195By Letter10088Jhon SmithA01151-2335600D
1218544195By Letter10088Jhon SmithA01270-38-233560D
1318544195By Letter10088Jhon SmithA01270-26-225960D
1418544195By Letter10088Jhon SmithA01227-294980D
1518544195By Letter10088Jhon SmithA0120350000D
1618544195By Letter10088Jhon SmithA01270-36-233560D
17
18DEF
1918544195By Letter10088Jhon SmithA01270-34-226460D
2018544195By Letter10088Jhon SmithA01202-270100D
2118544195By Letter10088Jhon SmithA01270-37-233560D
Result
 
Upvote 0
Please Test Pivot table Method Post #7 & #8 . it is very well for you. Go exactly with instructions,
 
Upvote 0
This is what I get when I clicked

Zot.xlsm
ABCDEFGHI
5Sr. DateCashier Bill #Customer NameProduct CodeAmountTaxNet
6ABC
718544195By Letter10088Jhon SmithVI-550500D
818544195By Letter10088Jhon SmithB011520967D
918544195By Letter10088Jhon SmithC016430300D
1018544195By Letter10088Jhon SmithC016110150D
1118544195By Letter10088Jhon SmithA01151-2335600D
1218544195By Letter10088Jhon SmithA01270-38-233560D
1318544195By Letter10088Jhon SmithA01270-26-225960D
1418544195By Letter10088Jhon SmithA01227-294980D
1518544195By Letter10088Jhon SmithA0120350000D
1618544195By Letter10088Jhon SmithA01270-36-233560D
17
18DEF
1918544195By Letter10088Jhon SmithA01270-34-226460D
2018544195By Letter10088Jhon SmithA01202-270100D
2118544195By Letter10088Jhon SmithA01270-37-233560D
Result
I was very reluctant to ask this follow up question. Because the codes were working fine. It may be some issue with my MS Excel.
Thanks a lot your guidance, time and patience with me. Stay blessed.
 
Upvote 0
I was very reluctant to ask this follow up question. Because the codes were working fine. It may be some issue with my MS Excel.
Thanks a lot your guidance, time and patience with me. Stay blessed.
It is strange indeed. I'm using 2016 too.

Keep update if you get it to work or find another solution.
 
Upvote 0
Still not working for me. I am attaching the file. Can you please guide me where am i wrong?
Fadee2.xlsm
In my reply (Post # 6) I mentioned
assuming you have list of centers in column N
means you have to have a list of all your centers in column N, starting from cell N14. The code filters your data based on values in column N, and copy/paste relevant data to your desired result worksheet, one by one.

after doing the above try this
VBA Code:
Sub abc()
Dim myrange As Range
Application.ScreenUpdating = False
Sheets("DATA").Activate
    LC = Cells(11, Columns.Count).End(xlToLeft).Column
    lr = Cells(Rows.Count, 1).End(xlUp).Row
   
ActiveSheet.Range("a11:j" & lr).AutoFilter
centerlr = Cells(Rows.Count, 14).End(xlUp).Row

For y = 12 To centerlr
    Sheets("DATA").Activate
    Range("a11:j" & lr).AutoFilter
    myvalue = Cells(y, 14)
    Range("A11:j" & lr).AutoFilter Field:=10, Criteria1:=myvalue
    
    Set myrange = Sheets("DATA").Range("a12:i" & lr)
    myrange.SpecialCells(xlCellTypeVisible).Copy

    With Sheets("DESIRED RESULT FORMAT")
        Sheets("DESIRED RESULT FORMAT").Activate
        If .Cells(5, 1) = "" Then
        .Cells(5, 1) = "S. NO"
        .Cells(5, 2) = "Date"
        .Cells(5, 3) = "Cashier"
        .Cells(5, 4) = "Bill #"
        .Cells(5, 5) = "Customer Name"
        .Cells(5, 6) = "Product Code"
        .Cells(5, 7) = "Amount"
        .Cells(5, 8) = "Tax"
        .Cells(5, 9) = "Net"
        End If
        destlr = Cells(Rows.Count, 1).End(xlUp).Row
        Sheets("DESIRED RESULT FORMAT").Range("a" & destlr + 1) = myvalue
        Sheets("DESIRED RESULT FORMAT").Range("a" & destlr + 2).PasteSpecial Paste:=xlPasteValues
    End With



Next y
Application.ScreenUpdating = True

End Sub



hope this helps....
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

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