Hi!
I have 2 subs in excel VBA module.
OBJECTIVE: combine code into one Sub / Function
First sub
DOES: CONTINUOUSLY monitor DDE updates with LinkOnData method,
DOES NOT: pass link strings to another sub
Second sub
DOES: Pass link strings to anoter sub
DOES NOT: monitor links contuinuously, only runs one cycle and stops.
Here is the code:
-------------------------------
Sub FitstSub()
Links = ActiveWorkbook.LinkSources(xlOLELinks)
If Not IsEmpty(Links) Then
For i = 1 To UBound(Links)
ActiveWorkbook.SetLinkOnData Links(i), "CallMyName"
'"CallMyName" is a sub that needs values of Links(i)
'Sub is called again and again,but values are not passed
Next i
Else
End If
End Sub
---------------------------------------
Sub SecondSub()
Links = ActiveWorkbook.LinkSources(xlOLELinks)
If Not IsEmpty(Links) Then
For i = 1 To UBound(Links)
ActiveWorkbook.SetLinkOnData Links(i), CallMyName(i)
'"CallMyName" is a sub that needs values of Links(i)
'Here I change receiving Sub to a Function NameX(i)
' it gets values on the first run, then stops
'If I try using "CallMyName(i)" I get error: Macro 'CallMyName(i) cannot be found
Next i
Else
End If
End Sub
I have 2 subs in excel VBA module.
OBJECTIVE: combine code into one Sub / Function
First sub
DOES: CONTINUOUSLY monitor DDE updates with LinkOnData method,
DOES NOT: pass link strings to another sub
Second sub
DOES: Pass link strings to anoter sub
DOES NOT: monitor links contuinuously, only runs one cycle and stops.
Here is the code:
-------------------------------
Sub FitstSub()
Links = ActiveWorkbook.LinkSources(xlOLELinks)
If Not IsEmpty(Links) Then
For i = 1 To UBound(Links)
ActiveWorkbook.SetLinkOnData Links(i), "CallMyName"
'"CallMyName" is a sub that needs values of Links(i)
'Sub is called again and again,but values are not passed
Next i
Else
End If
End Sub
---------------------------------------
Sub SecondSub()
Links = ActiveWorkbook.LinkSources(xlOLELinks)
If Not IsEmpty(Links) Then
For i = 1 To UBound(Links)
ActiveWorkbook.SetLinkOnData Links(i), CallMyName(i)
'"CallMyName" is a sub that needs values of Links(i)
'Here I change receiving Sub to a Function NameX(i)
' it gets values on the first run, then stops
'If I try using "CallMyName(i)" I get error: Macro 'CallMyName(i) cannot be found
Next i
Else
End If
End Sub