You are currently viewing the Excel VBA section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
I made a spreadsheet in XL03 but the VBA functions will not calculate in XL07!
I have saved it as macro enabled, the module exists, the functions appear in the fx dropdown list as I type!
I have set the "Trust Center" options in various ways but can not get rid of the error.
One of my functions:-
Code:
Function timval(tim_str As String) As Single
Dim hrh As Single
Dim minh As Single
hrh = 1 / 24
minh = hrh / 60
Dim hr_st As String
Dim min_st As String
Dim hr As Single
Dim min As Single
' extract hours and minutes from string
hr_st = Mid(tim_str, 1, 2)
min_st = Mid(tim_str, 4, 2)
' convert to numeric
If IsNumeric(hr_st) Then
hr = hr_st
Else
hr = 0
End If
If IsNumeric(min_st) Then
min = min_st
Else
min = 0
End If
' calculate time value in excel format
timval = (hr * hrh) + (min * minh)
End Function