golden14
09-11-2008, 11:57 AM
Hi,
I created a function for dealing with timecode conversion and it works just fine. The problem is that I have many cells with timecode and if one of the cells is blank, I get a #VALUE! error on the calculation for that cell. I would like the calculation to be 0 if a cell is blank.
I tried using an IF statement to check if the cell is blank, but either my syntax is incorrect or maybe I'm trying to pass data types incorrectly.
Here is an example of a cell value (with general formatting for the cell):
15:06:12:27
And here is the code snippet I'm testing with:
Function test(var1 As String, var2 As String)
Dim num1 As Integer
Dim num2 As Integer
Dim total As Double
num1 = Mid(var1, 1, 2)
num2 = Mid(var2, 1, 2)
If var1 = "" Then
total = 0
Else
total = num1 + num2
End If
test = total
End Function
Any ideas? Thanks for the help!
I created a function for dealing with timecode conversion and it works just fine. The problem is that I have many cells with timecode and if one of the cells is blank, I get a #VALUE! error on the calculation for that cell. I would like the calculation to be 0 if a cell is blank.
I tried using an IF statement to check if the cell is blank, but either my syntax is incorrect or maybe I'm trying to pass data types incorrectly.
Here is an example of a cell value (with general formatting for the cell):
15:06:12:27
And here is the code snippet I'm testing with:
Function test(var1 As String, var2 As String)
Dim num1 As Integer
Dim num2 As Integer
Dim total As Double
num1 = Mid(var1, 1, 2)
num2 = Mid(var2, 1, 2)
If var1 = "" Then
total = 0
Else
total = num1 + num2
End If
test = total
End Function
Any ideas? Thanks for the help!