Complie Error: Method or Data Member Not Found

KennyExcel

New Member
Joined
Jan 22, 2016
Messages
5
Hi all,

Going absolutely nuts trying to resolve this so was hoping somebody out there could show me the way. So I am trying to create a tree view within a userform and received some code from a friend but anytime I try to run this I receive the error as stated in the subject line. The piece of code it then highlights is ".tvList". Any help would be greatly appreciated. I have included my code below and highlighted the offending line:

Option Explicit

Private Sub cmdALL_Click()
Dim nd As Node

For Each nd In Me.tvList.Nodes
nd.Checked = True
Next nd

exitHandler:
Exit Sub

errHandler:
MsgBox "Could not select all items"
Resume exitHandler

End Sub

Private Sub cmdClear_Click()
Dim nd As Node

For Each nd In Me.tvList.Nodes
nd.Checked = False
Next nd

exitHandler:
Exit Sub

errHandler:
MsgBox "Could not clear all items"
Resume exitHandler

End Sub

Private Sub cmdClose_Click()
Unload Me
'move down one row
ActiveCell.Offset(0, 1).Activate
End Sub

Private Sub cmdOK_Click()
Dim nd As Node
Dim strSel As String
strSel = ""
For Each nd In Me.tvList.Nodes
If Left(nd.Key, 5) = "Child" Then
If nd.Checked = True Then
strSel = strSel & nd.Text & strSep
End If
End If
Next nd
If Len(strSel) > 0 Then
strSel = Left(strSel, Len(strSel) - Len(strSep))
ActiveCell.Value = strSel
Else
MsgBox "No selections"
End If
Unload Me
End Sub

Private Sub UserForm_Initialize()
Dim wb As Workbook
Dim rngMth As Range
Dim rngMD As Range
Dim cM As Range
Dim cMD As Range
Dim lParent As Long
Dim lChild As Long
Dim strParent As String

Set wb = ThisWorkbook
Set rngMth = wb.Names(strDVList).RefersToRange
lParent = 1
lChild = 1

With Me.tvList.Nodes
.Clear
For Each cM In rngMth
strParent = "Parent" & Format(lParent, "000")
If cM.Value <> cM.Offset(-1, 0).Value Then
.Add Key:=strParent, _
Text:=cM.Value
lParent = lParent + 1
.Add Relative:=strParent, _
Relationship:=tvwChild, _
Key:="Child" & Format(lChild, "000"), _
Text:=cM.Offset(0, 1).Value
lChild = lChild + 1

Else
strParent = "Parent" & Format(lParent - 1, "000")
.Add Relative:=strParent, _
Relationship:=tvwChild, _
Key:="Child" & Format(lChild, "000"), _
Text:=cM.Offset(0, 1).Value
lChild = lChild + 1
End If
Next cM
End With

End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top