Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6560245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:26:07+00:00 2026-05-25T13:26:07+00:00

For the sake of this question, let’s say I have an Excel data source

  • 0

For the sake of this question, let’s say I have an Excel data source spreadsheet with various liquor types.

(Cell A) | (Cell B)
Bacardi | Rum
Smirnoff | Vodka
Another Vodka | Vodka
Yet Another Vodka | Vodka
Malibu | Rum
Meyers | Rum

etc.

On a separate sheet within the document I want to list it as follows:

RUM
Bacardi
Malibu
Meyers
----------
VODKA
Smirnoff
Another Vodka
Yet Another Vodka

… where RUM is one category and VODKA is another.

How would I convert my data source (first example) into the second example?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:26:08+00:00Added an answer on May 25, 2026 at 1:26 pm

    It’s not the most elegant, and by far not the most efficient way, but here’s how to do it using 2 dictionaries in case you’re in a rush!

    Sub test()
    
    Dim varray As Variant, v As Variant
    Dim lastRow As Long, i As Long
    Dim results() As String
    Dim dict As Object, dict2 As Object
    Set dict = CreateObject("scripting.dictionary")
    Set dict2 = CreateObject("scripting.dictionary")
    
    lastRow = Sheet1.range("B" & Rows.count).End(xlUp).Row
    varray = Sheet1.range("A1:B" & lastRow).Value
    
    On Error Resume Next
    'Make the liquer dictionary
    For i = 1 To UBound(varray, 1)
        If dict.exists(varray(i, 2)) Then
            dict(varray(i, 2)) = dict(varray(i, 2)) & _
            vbLf & varray(i, 1)
        Else
            dict.Add varray(i, 2), (varray(i, 1))
        End If
    Next
    
    i = 1
    For Each v In dict
        dict2.Add i, UCase(v)
        i = i + 1
        results() = Split(dict.Item(v), vbLf)
            For j = 0 To UBound(results())
                dict2.Add i, results(j)
                i = i + 1
            Next
        dict2.Add i, "----------"
        i = i + 1
    Next
    
    Sheet2.range("A1").Resize(dict2.count).Value = _
    Application.Transpose(dict2.items)
    
    End Sub
    

    How it works: Using a dictionary to separate main categories and sub items (by concatenating them as the item for that key) is very convenient.
    You could work out ways to slap that back onto Excel but it requires resizing and It’s a hassle. Since the dictionary comes with the ability to transpose all keys or items, I opted to dump the key-item pairs (technically in order now) into another dictionary, but as items instead of keys, so I can keep dupes. It also let’s you do final data massaging like uCase the categories and add seperators, etc. Then I just transpose the result.

    Unconventional, maybe, but fun and works!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is heavily simplified for the sake of the question. Say I have a
This question is just for a sake of knowledge. I don't have any practical
Simple (I hope), HTML question. Let's say I have a column group that spans
For the sake of this question, let's suppose this table structure: People: PersonID int
For the sake of this question, let efficiency mean, more-or-less, page rendering speed. Albeit,
Let's create a value for the sake of this question: val a = 1
For the sake of this question, let us suppose that I want a row
For the sake of simplicity, let's say I have a Person class in Python.
For the sake of argument, let's just say I have to create a local
I have my markup like this (for argument's sake) <div id=content></div> <div id=layout></div> <div

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.