Dissecting a column/stack into multiple stacks. + COUNT problem

Zanjo

New Member
Joined
Jul 19, 2015
Messages
27
Greetings,

I've been working on a project and after hours of searching and experimenting I can't get this to work. I hope this is possible with a bit of help from you guys :)

There is actually two problems. I will start with the sequence of importance.

1) I have a list of names in (column B - Sheet1). In (column D - Sheet1), I list the frequency. (This can be changed to values if that makes it easier in some way)
I want to take the names from (column B - Sheet1) and sort them according to their frequency, (column D - Sheet1).
The sorting should take place in a different sheet, eg (column C - Sheet2). I would prefer, if there could be one row between the sorted names.
I will show a picture that will hopefully make it more clear.

IMAGE 1

2) On the 2nd sheet (Sheet2), I would love to be able to get a working dynamic range of every frequency. The normal OFFSET and COUNTA doesnt work since the different categories are in the same column. Is it possible to stop make a range stop count after a cell have no text?
Eg: =OFFSET(C4; 0; 0; COUNTA(C4:C100); 1) will result in a range C4:C17.

IMAGE 2

Here is a link to a testing document if needed.

EXCELFILE.xlsx

My time zone: CEST, UTC+2 hours.
Sincerely,
Zanjo
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I think VBA would be the only option. I dont know any VBA.
If the VBA code first could loop through the names column (sheet1 B), and pick all the ones that match a specifik frequency, then start posting it on sheet2, then continue loop through sheet1 B with another frequency etc.

The 2nd problem could maybe be solved with a formula, but I dont know how to stop counting when the input is empty "" .
 
Upvote 0
Solved it. I know nothing about VBA, just got piece by piece from google. I know I could use a real loop, but it doesnt matter much for me, this code works like a charm.
Here is the code:
******
Sub FILTRERING()
Dim SelectedRng As Range


Sheets("1 Installningar").Range("C4:E500").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Sheets("data").Range( _
"H10:H11"), CopyToRange:=Range("H4"), Unique:=False

Range("H4").Select
Selection.Copy
Range("H200").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste

Set SelectedRng = ActiveSheet.Range(Selection.Address)

Sheets("1 Installningar").Range("C4:E500").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Sheets("data").Range( _
"H12:H13"), CopyToRange:=SelectedRng, Unique:=False

Range("H4").Select
Selection.Copy
Range("H200").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste

Set SelectedRng = ActiveSheet.Range(Selection.Address)

Sheets("1 Installningar").Range("C4:E500").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Sheets("data").Range( _
"H14:H15"), CopyToRange:=SelectedRng, Unique:=False
Range("H4").Select
Selection.Copy
Range("H200").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste

Set SelectedRng = ActiveSheet.Range(Selection.Address)

Sheets("1 Installningar").Range("C4:E500").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Sheets("data").Range( _
"H16:H17"), CopyToRange:=SelectedRng, Unique:=False


End Sub
******
Cheers
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
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