Tricky Cell Selection


Posted by mike on January 31, 2002 5:01 AM

I have a long column of dates in column 1 (a whole year)and would like to use a macro to select the current date and then set the print area. But how do you make excel jump to the correct date?
Three hours and no luck, help would be appreciated.
Mike

Posted by Mike H on January 31, 2002 6:18 AM

If Column A has the dates, starting at A1 and B1 has today's date (use=TODAY()) then the following macro will start at A1 and move down the cells and stop at the cell which matches B1. This should therefore do what you want:

Sub FindToday()
'
' '
Range("A1").Select
Do
ActiveCell.Offset(1, 0).Range("A1").Select
Loop Until ActiveCell.Offset(0, 0) = Range("B1")
End Sub

Posted by Mike H on January 31, 2002 6:22 AM

If Column A has the dates, starting at A1 and B1 has today's date (use=TODAY()) then the following macro will start at A1 and move down the cells and stop at the cell which matches B1. This should therefore do what you want:

Sub FindToday()
'
' '
Range("A1").Select
Do
ActiveCell.Offset(1, 0).Range("A1").Select
Loop Until ActiveCell.Offset(0, 0) = Range("B1")
End Sub



Posted by Mike on January 31, 2002 1:27 PM

Mike many thanks for the tip as you sugessted it does select the cell exactly as i requested. But the darn thing won't let me set the print area "from" the cursor position it just shows it as a set range. Ah well it keeps me entertained, thanks again, Mike P.