S
scott
I have a cell A3 that contains the date like "200412" that my code finds
with the OFFSET command. In "CODE 1" below, sDateRange returns "12/1/2004"
as it should. However, "CODE 2" gives me an error if I try to set the
cellOffset variable to the OFFSET cell. I'm just trying to shorten my code.
Is it the data type that's causing a problem?
CODE 1 (Works):
Dim cell As Range, sDateRange As Date
Set cell = FindCell("myword", Sheets(1).Cells)
sDateRange = Right(cell.Offset(0, 2).Value, 2) & "/" & (Left(cell.Offset(0,
2).Value, Len(cell.Offset(0, 2).Value) - 2))
CODE 2 (Doesn't Work):
Dim cell As Range, cellOffset As Range, sDateRange As Date
Set cell = FindCell("myword", Sheets(1).Cells)
cellOffset = cell.Offset(0, 2).Value
sDateRange = Right(cellOffset, 2) & "/" & (Left(cell.Offset(0, 2).Value,
Len(cellOffset) - 2))
with the OFFSET command. In "CODE 1" below, sDateRange returns "12/1/2004"
as it should. However, "CODE 2" gives me an error if I try to set the
cellOffset variable to the OFFSET cell. I'm just trying to shorten my code.
Is it the data type that's causing a problem?
CODE 1 (Works):
Dim cell As Range, sDateRange As Date
Set cell = FindCell("myword", Sheets(1).Cells)
sDateRange = Right(cell.Offset(0, 2).Value, 2) & "/" & (Left(cell.Offset(0,
2).Value, Len(cell.Offset(0, 2).Value) - 2))
CODE 2 (Doesn't Work):
Dim cell As Range, cellOffset As Range, sDateRange As Date
Set cell = FindCell("myword", Sheets(1).Cells)
cellOffset = cell.Offset(0, 2).Value
sDateRange = Right(cellOffset, 2) & "/" & (Left(cell.Offset(0, 2).Value,
Len(cellOffset) - 2))