LastRowID = Sheet2.Cells(, "A").End(xlUp).Rowįor Each ID In Range(Sheet2.Cells(2, 1), Sheet2.Cells(LastRowID,Īnd here's what your coding window should look like (we've used the underscoreĬharacter to break up that long first line):įor the first part of the If statement, we don't do anything. Here's the full code to add to your NodeClick event: If it does, then we can use Offset to get the informationįrom that row. The text from the Node that was clicked and see if matches a value from the We can loop round this columnĪnd check if the value in the cell matches Node.Text. If you have a look at the data in Sheet2 of your spreadsheet, you'll see that The child node that has been clicked can be retrieved using the Text property If the node key is anything else then it must be a child node: Or Node.Key = "Asia" Or Node.Key = "Australasia" Or Node.Key If Node.Key = "Africa" Or Node.Key = "Americas" We only have five parent nodes so we can create a long line of Or clauses: We can use the Key properties to detect if a parent node is selected: This object variable has properties of its own ![]() ![]() ![]() Notice that between the round brackets of the NodeClick event, there is an Private Sub Treeview1_NodeClick( ByVal Node As MSComctlLib.Node To access it, from the dropdown boxes at the top of the codingĮditor, select the name of your Treeview, which is Treeview1 for us:įrom the dropdown on the right, select NodeClick: To detect if a parent or child node was clicked on, there is inbuilt eventĬalled NodeClick.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |