I have absolutely no idea how to create separate subs
/functions
to shorten the code
. I am referring to those subs(something as integer, etc)
Below we have this code
that resides in my core module
Set els = IE.Document.getelementsbytagname("a")
For Each el In els
If Trim(el.innertext) = "Documents" Then
colDocLinks.Add el.href
End If
Next el
For Each XML_link In colDocLinks
LoadPage IE, CStr(XML_link)
For Each el In IE.Document.getelementsbytagname("a")
If el.href Like "*[0-9].xml" Then
With Worksheets("CONTROL_ROOM").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
.NumberFormat = "@"
.Value = Ticker
.Offset(0, 1).Value = el.href
End With
Debug.Print el.innertext, el.href
colXMLPaths.Add el.href
End If
Next el
Next XML_link
I really need to shorten my code
. How could i create a separate sub
or function
instead of having this chunk of code
into my main module
?
Books offer over-simplistic examples and have not been any help to me in real situations like this one. Do i need to make declarations such as Dim els
inside the separate Sub
or Function
? Thank you for your patience in advance.
And most importantly no-matter how much time i look to these examples i cannot figure out which variables i put in here:
(Private) Sub / (Private) Function ( variables ?)
+++Any good examples/links will help.