I am trying to compare a node key in my treeview control (Excel 2010) to a value in a range. If the two values match, then make the node bold.
I am using the following piece of code:
Private Sub Highlight_Tree(ByVal highlight_node As Object)' Parentnode previously declared as node - had to change to avoid type mismatch error.Dim row As RangeDim rngcomments As RangeDim wkscomments As WorksheetDim n As ObjectSet wkscomments = ThisWorkbook.Worksheets("Comments")Set rngcomments = wkscomments.Range("Comments") Do Until highlight_node Is Nothing For Each row In rngcomments.Rows Debug.Print row.Columns(1).Value, highlight_node.Key If row.Columns(1).Value = highlight_node.Key Then With highlight_node.Font .Bold = True End With Exit For End If Next row Highlight_Tree highlight_node.Child Set highlight_node = highlight_node.Next LoopEnd Sub
Well I changed my code but I'm still getting the same error.
Do Until highlight_node Is Nothing For Each row In rngcomments.Rows Debug.Print row.Columns(1).Value, highlight_node.Key If row.Columns(1).Value = highlight_node.Key Then highlight_node.Bold = True Exit For End If Next row Highlight_Tree highlight_node.Child Set highlight_node = highlight_node.Next Loop
Seeing no response from asker and not for points just to clarify, rorya meant for you to
replace this
With highlight_node.Font
.Bold = True
End With
by this
With highlight_node
.Bold = True
End With
gowflow
0
The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.
One of a set of tools we're offering as a way of saying thank you for being a part of the community.
gives a "type mismatch" error when passing treeview.nodes(1) to the procedure.
setting it to object eliminated the error. But I can't get this to work at all. I have attached a copy of the entire spreadsheet. Maybe I am missing a reference ? This is driving me crazy. Menu-Documentation-V1.0---Copy.xlsm
Can you replace your Treeview control version 5 with version 6? I don't have version 5, which is what you appear to be using, so the treeview simply gets removed. This may be part of the problem, since you also have a reference to version 6 of the common controls.
I thought - I really thought I had a version 6 treeview control. And I never thought to look at that.
This is a great relief.
Cheers,
Craig
0
Featured Post
ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.
One of a set of tools we're offering as a way to say thank you for being a part of the community.
Windows Explorer lets you open cabinet (cab) files like any other folder.
In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Manually copying shapes and their assigned macros one by one to a new location can be tedious, but if you use the Excel utility workbook attached to this article, the process will be much quicker and easier.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210 (2 * 3 * 5 * 7) or 2310 (2 * 3 * 5 * 7 * 11).
The larger templa…