List items according to an attribute

cicco_71

New Member
Joined
Jul 20, 2018
Messages
7
Office Version
  1. 2016
Platform
  1. Windows
Dear Mr. and Mrs. Excels,

I'm looking for a solution for the following problem:

I have a huge list (28 000 rows) of items (practically document subchapter titles) that are connected to their parent items (main chapters) as follows:

Chapter titleSubchapter titleStaring page no.
1.1 Cooking fish1.1.1 Bass5
1.1 Cooking fish1.1.2 Salmon12
1.1 Cooking fish1.1.3 Catfish50
1.1 Cooking fish1.1.4 Hake61
1.2 Steaming fish1.2.1 Trout75
1.2 Steaming fish1.2.2 Salmon32
and so on...

I need to make a function (I guess VBA?) that takes "1.1 Cooking fish" as input (for example in cell A1) and fills the range A2:B999 with the corresponding subchapters and their page numbers.

How do I start?...

Thank you very much!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi & welcome to MrExcel.
How about
+Fluff 1.xlsm
ABCDEFG
1Chapter titleSubchapter titleStaring page no.1.1 Cooking fish
21.1 Cooking fish1.1.1 Bass51.1.1 Bass5
31.1 Cooking fish1.1.2 Salmon121.1.2 Salmon12
41.1 Cooking fish1.1.3 Catfish501.1.3 Catfish50
51.1 Cooking fish1.1.4 Hake611.1.4 Hake61
61.2 Steaming fish1.2.1 Trout75  
71.2 Steaming fish1.2.2 Salmon32  
8
Main
Cell Formulas
RangeFormula
F2:G7F2=IFERROR(INDEX(B$2:B$30000,AGGREGATE(15,6,(ROW($A$2:$A$30000)-ROW($A$2)+1)/($A$2:$A$30000=$F$1),ROWS(F$2:F2))),"")
 
Upvote 0
Hi & welcome to MrExcel.
How about
Thank you very much! Unfortunately it won't do, because I need the space down below and later in between the lines, (to insert new chapters manually) so as I see it, formulas are out of the question. I need the sheet to be filled with static text and values, that's why I'm thinking about VBA codes.
 
Upvote 0
Ok, what sheet is your data on?
 
Upvote 0
Ok, what sheet is your data on?
It's on a different sheet that would function as a database. To just draw you the picture, I have 700 chapters, and each and every one should have their own sheet with the corresponding subchapters on it for evaluation (clearly I'm not writing a cookbook really). Running the code manually for all 700 wouldn't be a problem (I have colleagues for that ?), though it would seem useful later not to do that either...
 
Upvote 0
Ok, how about
VBA Code:
Sub cicco()
   Dim Cl As Range
   Dim Ws As Worksheet
   Dim i As Long
   
   Set Ws = Sheets("ref_Database")
   With CreateObject("scripting.dictionary")
      For Each Cl In Ws.Range("A2", Ws.Range("A" & Rows.Count).End(xlUp))
         .Item(Cl.Value) = Left(Cl.Value, InStr(1, Cl.Value, " ") - 1)
      Next Cl
      For i = 0 To .Count - 1
         Sheets.Add.Name = .items()(i)
         Ws.Range("A1").AutoFilter 1, .keys()(i)
         Ws.AutoFilter.Range.Columns("B:C").Copy Range("A1")
      Next i
      Ws.AutoFilterMode = False
   End With
End Sub
 
Upvote 0
Solution
Ok, how about
VBA Code:
Sub cicco()
   Dim Cl As Range
   Dim Ws As Worksheet
   Dim i As Long
  
   Set Ws = Sheets("ref_Database")
   With CreateObject("scripting.dictionary")
      For Each Cl In Ws.Range("A2", Ws.Range("A" & Rows.Count).End(xlUp))
         .Item(Cl.Value) = Left(Cl.Value, InStr(1, Cl.Value, " ") - 1)
      Next Cl
      For i = 0 To .Count - 1
         Sheets.Add.Name = .items()(i)
         Ws.Range("A1").AutoFilter 1, .keys()(i)
         Ws.AutoFilter.Range.Columns("B:C").Copy Range("A1")
      Next i
      Ws.AutoFilterMode = False
   End With
End Sub
Thank you very much, that solves my basic problem!!! (y)
 
Upvote 0
Ok, how about
What do I change in the code, if I want the data to be placed into a template sheet? Like I wanted to make a copy of a template sheet, and paste the relevant subchapters into B11 and below? Can you help me with that?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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