PC Review


Reply
Thread Tools Rate Thread

Date find Macro

 
 
Johnnyboy5
Guest
Posts: n/a
 
      8th Mar 2010
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 Auto_Open()
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
 
Reply With Quote
 
 
 
 
Paul C
Guest
Posts: n/a
 
      8th Mar 2010
The macro you show finds seven days prior to today, and you are now asking
for 7 days after and to switch to column A instead of Row 1.

The changes are relatively simple

Change MsgBox "This action will put the date to 7 days before today's date"
to MsgBox "This action will put the date to 7 after before today's
date"

Change Set rngRow1 = .Rows(1)
to Set rngRow1 = .Columns(1)

Change dateToday = Date - 7
to dateToday = Date +7

If you really want to be picky change all of the rngRow1 to rngCol1 so as
not to create confusion due to the name of the range, but this is not
necessary for the program to work, it just makes it easier to look at.

--
If this helps, please remember to click yes.


"Johnnyboy5" wrote:

> 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 Auto_Open()
> 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
> .
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      8th Mar 2010
Sub gotodateplus7()
Columns("E").Find(What:=Date + 7, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Johnnyboy5" <(E-Mail Removed)> wrote in message
news:7b4f0862-4683-4221-8c47-(E-Mail Removed)...
>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 Auto_Open()
> 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


 
Reply With Quote
 
Johnnyboy5
Guest
Posts: n/a
 
      9th Mar 2010
On 8 Mar, 14:15, Paul C <Pa...@discussions.microsoft.com> wrote:
> The macro you show finds seven days prior to today, and you are now asking
> for 7 days after and to switch to column A instead of Row 1.
>
> The changes are relatively simple
>
> Change *MsgBox "This action will put the date to 7 days before today's date"
> to * * * * *MsgBox "This action will put the date to 7 after before today's
> date"
>
> Change *Set rngRow1 = .Rows(1)
> to * * * * *Set rngRow1 = .Columns(1)
>
> Change *dateToday = Date - 7
> to * * * * *dateToday = Date +7
>
> If you really want to be picky change all of the rngRow1 to rngCol1 so as
> not to create confusion due to the name of the range, but this is not
> necessary for the program to work, it just makes it easier to look at.
>
> --
> If this helps, please remember to click yes.
>
>
>
> "Johnnyboy5" wrote:
> > 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 Auto_Open()
> > 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
> > .- Hide quoted text -

>
> - Show quoted text -


Thanks to Paul C will change it tonight - well spotted I meant it to
be 7 before the current date.

Johnnyboy
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help - Need a Macro/Popup to Find a Date in a Sheet. Kev - Radio Man Microsoft Excel Programming 6 31st May 2010 06:23 AM
Macro to find matching date and copy values to another sheet =?Utf-8?B?VGlnZXI=?= Microsoft Excel Misc 3 13th Aug 2007 01:45 PM
macro to find date in the string nshanmugaraj Microsoft Excel Programming 3 4th Mar 2006 12:30 PM
macro to find date format in a cell and delete that entire row vikram Microsoft Excel Misc 8 30th Apr 2004 05:45 PM
Problems with Find and Date Fields in Excel macro Nick Marshall Microsoft Excel Programming 1 15th Oct 2003 05:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:19 AM.