J
Johnnyboy5
I need a marco that when I click on the macro button it will jump to a
date in column A which is 7 days foward from the current date. This
is rather than scrolling all the way down the column to find the
current week. Someone did me one for the same task but then I was
using a row not a column.
thanks
Johnnyboy
Here is that macro (for row)
Macro1 Macro
' Macro recorded 08/08/2009 by john hayward
'
Sub Auto_open()
'Sub Autpen()
MsgBox "This action will put the date to 7 days before today's date"
Dim rngRow1 As Range
Dim rngToFind As Range
Dim dateToday As Date
'Edit Sheet1 to match your worksheet
Sheets("Planner").Select
With ActiveSheet
Set rngRow1 = .Rows(1)
End With
dateToday = Date - 7
With rngRow1
Set rngToFind = .Find(What:=dateToday, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
End With
If Not rngToFind Is Nothing Then
rngToFind.Select
ActiveWindow.ScrollRow = rngToFind.Row
ActiveWindow.ScrollColumn = rngToFind.Column
Else
MsgBox "Date " & dateToday & " not found. It might be the weekend.
Get a life !"
End If
End Sub
date in column A which is 7 days foward from the current date. This
is rather than scrolling all the way down the column to find the
current week. Someone did me one for the same task but then I was
using a row not a column.
thanks
Johnnyboy
Here is that macro (for row)
Macro1 Macro
' Macro recorded 08/08/2009 by john hayward
'
Sub Auto_open()
'Sub Autpen()
MsgBox "This action will put the date to 7 days before today's date"
Dim rngRow1 As Range
Dim rngToFind As Range
Dim dateToday As Date
'Edit Sheet1 to match your worksheet
Sheets("Planner").Select
With ActiveSheet
Set rngRow1 = .Rows(1)
End With
dateToday = Date - 7
With rngRow1
Set rngToFind = .Find(What:=dateToday, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
End With
If Not rngToFind Is Nothing Then
rngToFind.Select
ActiveWindow.ScrollRow = rngToFind.Row
ActiveWindow.ScrollColumn = rngToFind.Column
Else
MsgBox "Date " & dateToday & " not found. It might be the weekend.
Get a life !"
End If
End Sub