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 521625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:16:10+00:00 2026-05-13T08:16:10+00:00

I have a TreeView in excel 2007 with checkboxes. I want the checkboxes to

  • 0

I have a TreeView in excel 2007 with checkboxes.

  • I want the checkboxes to be all selected when the tree is populated
  • I want that when I select/unselect a parent node of the list, all its children are selected/unselected

Here is the code I have written so far:

Private Sub UserForm_Initialize()

 'Set control defaults
 With Me
      .CommandButton1.Caption = "Close"
      .Label1 = vbNullString
      .ZonesTree.LineStyle = tvwRootLines
 End With

 'Populate the Treeview
 Call TreeView_Populate

End Sub

Private Sub TreeView_Populate()

Dim wbBook As Workbook
Dim wsZones As Worksheet
Dim rngZones As Range
Dim rngCinemas As Range
Dim lngRows As Long

Set wbBook = ThisWorkbook
Set wsZones = wbBook.Worksheets("Cinemas")

'lngRows = wsZones.Range("A65536").End(xlUp).row
lngRows = wsZones.UsedRange.Rows.Count
Set rngZones = wsZones.Range("A1:A" & lngRows)

Dim rngBC As Range
Set rngBC = wsZones.Range("B1:C" & lngRows)


Dim rCell As Range
Dim lastCreatedKey As String
Dim rowCount As Integer
Dim currentRowRange As Range
rowCount = 1
lastCreatedKey = ""

With Me.ZonesTree.Nodes
      'Clear TreeView control
      .Clear

        For Each rCell In rngZones
            If Not rCell.Text = "" Then
                .Add Key:=rCell.Text, Text:=rCell.Text
                lastCreatedKey = rCell.Text
            Else
                Set currentRowRange = rngBC.Rows(rowCount)
                .Add Relative:=lastCreatedKey, relationship:=tvwChild, Key:=currentRowRange.Cells(, 2).Text, Text:=currentRowRange.Cells(, 1).Text
            End If
            rowCount = rowCount + 1
        Next rCell
End With
End Sub

Private Sub Treeview1_NodeClick(ByVal Node As MSComctlLib.Node)
 Me.Label1.Caption = Node.Key
End Sub


Private Sub CommandButton1_Click()
 Unload Me
End Sub

This tree picks data from a sheet in this manner:

—A———B———C———D

ParentNode

————ChildNode

————ChildNode

————ChildNode

ParentNode

————ChildNode

————ChildNode

ParentNode

————ChildNode

etc… (you get the idea, its an excel sheet…)

What is the vba code to select/unselect the boxes?? I have been searching a lot and couldn’t find an answer to this easy problem….

Thx in advance!

  • 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-13T08:16:10+00:00Added an answer on May 13, 2026 at 8:16 am

    On access which I assume uses the same control the property you use is .checked

    Just set that to true for the boxes you want ticked

    Here is a code sample

    Set iNode = objTree.Nodes.Add(strParent,tvwChild, strKey, strText)
    iNode.Checked = true
    

    You should be to adapt it to work in excel

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

Sidebar

Related Questions

No related questions found

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.