It is real easy to define a sub or function but the choice on which may be the hard part. For example...
Public Function MyFunction() As Long
End Function
Public Sub MySub()
End Sub
So your choices are...
Public/Private Function/Sub (optional argument list) as somethingoranother
End Function/Sub
Just remember, a sub does not "traditionally" return anything and a function normally only returns one thing.
Now, for further clarification on the "traditionally" statement. A sub can return many values as a function can also do but both do these indirectly (for lack of a better way to word it...)
For example...
Private Sub Command1_Click()
Dim MyInputString As String, MyOutputString As String
MyInputString = "This is a test."
MySub MyInputString, MyOutputString
MsgBox MyOutputString
End Sub
Private Sub MySub(InStr As String, OutStr As String)
OutStr = InStr
End Sub
So how/why does this work? Well in VB6.0 and vba (if I remember correctly about vba), arguements are passed by ref by default and as such, the called procedure can change those values. However, if the procedure declares the arguements ByVal then VB makes a copy of that value before the called procedure recieves it.
Now you can do the same thing with the arguements of a function if you so wish or you can leverage the power of the function to return a UDT (User Defined Type)...
Private Type MyType
A As Integer
B As Long
C As Byte
End Type
Private Sub Command1_Click()
Dim T As MyType
T = ReturnMyType
End Sub
Private Function ReturnMyType() As MyType
Dim T As MyType
T.A = 1
T.B = 2
T.C = 3
ReturnMyType = T
End Function
So combining the power of the UDT Type declaration, which by the way, if you can declare it normally like Dim A As Interger, the type can hold it, and the power of a function, you can return a whole lot of information.
Now, lets talk about your large procedure...
First things to break out are those things that repeat themselves, meaning code you have that is the same in several place within your procedure. Next up would be those pieces of code that do something to find something and then return that something/value.
Good Luck