Date operations in Excel VBA

1

I was asked to perform a macro in VBA and I am having a problem that I have to perform an operation with dates, I recover the date in the format "hh, mm" [15:59 ] and trying to make a subtraction between two dates generates an error 13, that the types do not match. Any suggestions that recommend me, the truth I've never done macros. Thank you very much in advance.

h2 = Format(Range(strColumnaC).Value, "hh:mm")
h1 = Format(Range(strColumnaC).Value, "hh:mm")
h3 = h2-h1
    
asked by Silvestre Silva 14.09.2017 в 16:28
source

1 answer

3

I have solved the problem with the help of the comments.

h1 = Range(strColumnaC).Value
h2 = Range(strColumnaC).Value 

And finally I calculate the result in this way, "n" , it indicates that the result I want is in minutes format.

h3 = DateDiff("n", h1, h2)
    
answered by 14.09.2017 / 17:48
source