Home Newsletter

Nederlandse pagina niet beschikbaarHome > Article index > Treeview control > Examples

An MSForms (all VBA) treeview

Pages in this article

  1. Features
  2. How To Use
  3. Examples


This page displays some examples where our treeview has been used.


Our RefTreeAnalyser also implements the treeview control, as you can see here:

Screenshot of RefTreeAnalyser, the ultimate Excel formula auditing tool.

The City Of Amsterdam

The Engineering Desk of the City of Amsterdam has implemented our Treeview in a VBA driven tool which is used by the technical designers of the Engineering desk so their drawings comply with the Dutch CAD standard NLCS. This is what the treeview looks like in their software:

Screenshot of technical drawing tool.

Extended Project Explorer

(by Peter Thornton)

The purpose of this file is to show a few ways how the VBA Treeview can be used in a real life app. The treeview lists projects and modules similar to the VBE's (Visual Basic Editor) Project Explorer, but the branches are extended to list procedures and declarations. These can be double clicked and in turn activated in the VBE.

Other features include routines to search the treeview, return details of the treeview to a sheet to document projects, and more. Please refer to the main demo files for the most recent version of the VBA Treeview.

It looks like this:

Screenshot of Extended Project Explorer.

Access and Word users: please note documentation is included in the main Excel demo.

Download The Extended Project Explorer V1.0 (Updated Dec 04, 2013, downloaded: 5.687times)

Access Archon article

Description: Helen Feddema from Access Watch published an Access Archon article with a sample .accdb database using the Treeview alternative that works in 64-bit Office; also includes a sample .mdb database that uses the native Treeview control.

XER toolkit

The XER Toolkit is an MS Excel based application that can read, display and analyse data from Oracle's Project Management application, Primavera. The toolkit helps to improve the quality of project schedules by providing visibility without the requirement for (expensive) Primavera licences. As an enterprise system, the data within Primavera is hierarchically arranged and so the Treeview developed by JKP has become an integral and essential part of the toolkit's data access functionality. See the video. One of the screens in the tool:

Treeview data selector

Spanish diseases classification list

From Diego Pereira: This treeview loads the International Classification of Diseases in Spanish. By entering a word, a part of a word or a ICD10 code, one can locate matching nodes, highlight them and expand them. The main purpose of this example is to serve as a simple implementation of the Treeview in an Access style.

Download the sample Access accdb database (05 Mar 2014, downloaded 4.240 times)

Treeview showing Spanish Diseases classifications

Sheet navigation tool

Yves Leboutte sent us these screenshots:

Go To sheet: Allows to jump to worksheet < List of countries
Jump to sheet

Go To Item: To jump to 1 item (rows)
Jump to item

Item Selection: Allows to save options to some items in 1 or all childs sheets.
Item selection

Filtered tree

Tiago Costa from EWEN Energy shared a treeview with us which the user can filter. The filtering is implemented quite simple by filtering the table containing the source data for the tree and rebuilding the tree after filtering using the filtered table (in a Worksheet). I particularly like the looks of the form, very "modern UI"-like:

Nice form with filtered tree

Template system

Template system

FREE open source Access database for IT Asset Management purposes

Florian Rossmark created an IT Assets database, a free open source IT Assets management database project based on Microsoft SQL server as a back end and Microsoft Access as front end. The Wiki module in the database was accomplished by using the TreeView control for easy navigation through structured data controlled by the actual end user.

Template system

Peter Denney's showing a popup with more information pertaining to a node

Template system

Your implementation

We're always interested to see how people have implemented the VBA Treeview. So please feel free to send a screenshot with a brief description or relevant details.



Showing last 8 comments of 48 in total (Show All Comments):


Comment by: Lakazet (27-10-2020 21:20:00) deeplink to this comment

Hi guys, my treeview on excel x86 working as well but I want running it on x64, anybody help me for follow codes:

Private Sub CBAddRoot_Click()

    Dim rngData As Range
    Dim lngRow As Long
    Dim objNode As Node
    Dim objRootNode As Node
    Dim obj As Node
    Dim ch As Node
    Dim strPrevName As String
    Dim lngCount As Long
    Set rngData = ActiveSheet.Range("A1:D56")
    strPrevName = ""
    lngCount = 0
    For lngRow = 1 To rngData.Rows.Count
        If rngData.Cells(lngRow, 1) <> strPrevName Then
            lngCount = lngCount + 1
            Set objRootNode = TreeView1.Nodes.Add(, , "Key" & lngCount)

            objRootNode.Text = rngData.Cells(lngRow, 1)

        End If

            lngCount = lngCount + 1

         Set objNode = TreeView1.Nodes.Add(objRootNode, tvwChild, "Key" & lngCount)

        objNode.Text = rngData.Cells(lngRow, 2) & " " & rngData.Cells(lngRow, 11).Text

         lngCount = lngCount + 1

        Set obj = TreeView1.Nodes.Add(objNode, tvwChild, "Key" & lngCount)

        obj.Text = rngData.Cells(lngRow, 3) & " " & rngData.Cells(lngRow, 12).Text

     lngCount = lngCount + 1

     Set ch = TreeView1.Nodes.Add(obj, tvwChild, "Key" & lngCount)

        ch.Text = rngData.Cells(lngRow, 4) & " " & rngData.Cells(lngRow, 13).Text

        strPrevName = rngData.Cells(lngRow, 1)


End Sub

Comment by: Jan Karel Pieterse (28-10-2020 09:30:00) deeplink to this comment

Hi Lakazet,

There is nothing in your code that I would expect to cause an issue in 64 bit Excel. What error(s) do you get?

Comment by: Lakazet (28-10-2020 13:24:00) deeplink to this comment

Hi jan, I import this code in userform (ufDemo) and add button for that, but when running ufDemo and press button some error occurred for example undefined variables types that I fix it with clsnode instead Node, but not recognized text and as it, I dont know how solve it

Comment by: Jan Karel Pieterse (28-10-2020 13:44:00) deeplink to this comment

Hi Lakazet,

You'll have to study the demo file and use the syntax explained there. If your system does not recognize clsNode then I suspect you haven't copied the class module clsNode?

Comment by: Lakazet (28-10-2020 14:26:00) deeplink to this comment

yes I do it but since I am a beginner, I didn't understanding

Comment by: Jan Karel Pieterse (28-10-2020 15:21:00) deeplink to this comment

Hi Lakazet,

If you're willing to pay for some consulting we might me able to help out?

Comment by: karim (31-3-2022 07:01:00) deeplink to this comment

treeview to access

Comment by: Jan Karel Pieterse (31-3-2022 10:28:00) deeplink to this comment

Hi Karim,

What is your question please?

Have a question, comment or suggestion? Then please use this form.

If your question is not directly related to this web page, but rather a more general "How do I do this" Excel question, then I advise you to ask your question here: www.eileenslounge.com.

To post VBA code in your comment, use [VB] tags, like this: [VB]Code goes here[/VB].