I really don't understand what's wrong with my types.
I'm using Option Explicit declarations.
I have a string (libstr) defined as a public variable.
I have a secondary sub that is being called by my main sub, and this secondary sub alters libstr and sends it to another function.
This third function returns a string, based on libstr.
The applicable code should be this:
Option Explicit
Public dateassess As Date, Counter As Integer, LastRow As Long, libstr As String
Sub NewRate()
...
Application.OnTime Now + TimeValue("00:01:00"), "rateAssign"
End Sub
Sub rateAssign()
...
For p = 1 To LastRow
q = ActiveSheet.Cells(p, "M").Value
If IsDate(q) Then
If Month(q) = Month(dateassess) Then
libstr = Cells(p, "M").Offset(0, 5).Value
Cells(p, "M").Offset(0, -3).Value = Worksheets("Calcs").Cells(Counter, 2).Value + LibAdj(libstr) / 10000
End If
Counter = Counter + 1
End If
Next p
End Sub
Function LibAdj(ByVal libstr As String) As Double
Dim D As Double
Dim I As Long
Dim N As Long
Dim SubStr As String
LibAdj = 0
SubStr = "-": GoSub FindNumber
SubStr = "+": GoSub FindNumber
Exit Function
FindNumber:
Do
I = InStr(N + 1, libstr, SubStr)
If I > 0 Then N = I
Loop While I > 0
If N <> 0 Then LibAdj = Val(Mid(libstr, N, Len(libstr) - N + 1))
Return
End Function
The error takes place in rateAssign, on the line where the function LibAdj is called.
Any help at all would be encouraging.
Bookmarks