The attached has two new named ranges ChannelData and ChannelIndicator, and this code for the userform.
Private Sub cmd_apply_Click()
Dim CurrentChart As Chart, Fname As String
If Not rngindicatedChannel Is Nothing Then
With rngindicatedChannel
.Cells(1, 1).Value = Val(Me.TextBox1.Text)
.Cells(1, 2).Value = Val(Me.TextBox2.Text)
.Cells(1, 3).Value = Val(Me.TextBox3.Text)
End With
On Error Resume Next
rngChannelIndicator.Value = Me.cbo_channel.Value
On Error GoTo 0
End If
End Sub
Private Sub cbo_channel_Change()
If Not rngindicatedChannel Is Nothing Then
With rngindicatedChannel
Me.TextBox1.Text = CStr(.Cells(1, 1))
Me.TextBox2.Text = CStr(.Cells(1, 2))
Me.TextBox3.Text = CStr(.Cells(1, 3))
End With
End If
End Sub
Private Sub cmd_ok_Click()
'Verwijzing naar update sub
cmd_apply_Click
'Form Sluiten
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim cPart As Range
Dim cLoc As Range
For Each cPart In ThisWorkbook.Names("ChannelList").RefersToRange
With Me.cbo_channel
.AddItem cPart.Value
'.List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value
End With
Next cPart
Me.cbo_channel = CStr(rngChannelIndicator)
End Sub
Function rngChannelIndicator() As Range
On Error Resume Next
Set rngChannelIndicator = ThisWorkbook.Names("ChannelIndicator").RefersToRange.Cells(1, 1)
On Error GoTo 0
End Function
Function rngindicatedChannel() As Range
With cbo_channel
If -1 < .ListIndex Then
On Error Resume Next
Set rngindicatedChannel = ThisWorkbook.Names("ChannelData").RefersToRange.Rows(1).Offset(.ListIndex, 0)
On Error GoTo 0
End If
End With
End Function
Bookmarks