T
t.aadland
I'm trying to write a macro in Excel 2003. In this macro, I want to
use the date values of three different dates, but I'm not able to make
it work. The code below shows three different methods I've tried, but
they all just return 0. I have also tried using Double or Date instead
of Integer, but it turns out the same. When debugging this code, it
looks like the second range selection doesn't work. Any suggestions?
With ActiveSheet
.Range(.Cells(5, 9), Cells(7, 9)).Select
'...
Dim dateBefore As Integer
Dim dateSepTest As Integer
Dim dateAfter As Integer
dateBefore = .Range(.Cells(5, 1)).Value
dateSepTest = .Range(.Cells(6, 1)).Formula
.Range(.Cells(7, 1)).Select
dateAfter = Selection.Formula
MsgBox("dateBefore = " & dateBefore)
MsgBox("dateSepTest = " & dateSepTest)
MsgBox("dateAfter = " & dateAfter)
End With
use the date values of three different dates, but I'm not able to make
it work. The code below shows three different methods I've tried, but
they all just return 0. I have also tried using Double or Date instead
of Integer, but it turns out the same. When debugging this code, it
looks like the second range selection doesn't work. Any suggestions?
With ActiveSheet
.Range(.Cells(5, 9), Cells(7, 9)).Select
'...
Dim dateBefore As Integer
Dim dateSepTest As Integer
Dim dateAfter As Integer
dateBefore = .Range(.Cells(5, 1)).Value
dateSepTest = .Range(.Cells(6, 1)).Formula
.Range(.Cells(7, 1)).Select
dateAfter = Selection.Formula
MsgBox("dateBefore = " & dateBefore)
MsgBox("dateSepTest = " & dateSepTest)
MsgBox("dateAfter = " & dateAfter)
End With