PC Review


Reply
Thread Tools Rate Thread

Autofilter using macro

 
 
jsurkin@gmail.com
Guest
Posts: n/a
 
      5th Mar 2007
I'm trying to create a macro that will select a range of rows fitting
a certain criterion, then insert today's date into an empty cell in
each row that matches the criterion. I set up the macro to insert the
formula into the top cell of the range and then copy the formula down
the range. My problem is that I have to run this macro daily, and the
range of rows changes every day. I set up the macro using today's
report, so it contains today's ranges, but I need to alter the macro
so that it selects the active range for each day. Here is the
relevant
portion of the macro:


Selection.AutoFilter Field:=8, Criteria1:="Ad"
Range("L87").Select
ActiveCell.FormulaR1C1 = "=TODAY()"
Selection.Copy
Range("L307:L5100").Select
ActiveSheet.Paste


I'm a complete novice at macros, so if anyone has any ideas for a
code
that would work, please help!


Thanks,
Jill

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      5th Mar 2007
From the code, it looks like you're showing the Ad codes in column H and putting
today's date in column L for those rows.

If that's true, ...

Option Explicit
Sub testme()

Dim wks As Worksheet

Set wks = ActiveSheet

With wks
.AutoFilterMode = False
.Range("a1").CurrentRegion.AutoFilter field:=8, Criteria1:="Ad"

'just start with the first column (A for my data)
With .AutoFilter.Range.Columns(1)
If .Cells.Count = 1 Then
'only headers, do nothing
Else
'avoid the header row, and come over 11 columns (A -> L)
With .Resize(.Rows.Count - 1).Offset(1, 11) _
.Cells.SpecialCells(xlCellTypeVisible)
.Formula = "=today()"
End With
End If
End With
End With

End Sub


(E-Mail Removed) wrote:
>
> I'm trying to create a macro that will select a range of rows fitting
> a certain criterion, then insert today's date into an empty cell in
> each row that matches the criterion. I set up the macro to insert the
> formula into the top cell of the range and then copy the formula down
> the range. My problem is that I have to run this macro daily, and the
> range of rows changes every day. I set up the macro using today's
> report, so it contains today's ranges, but I need to alter the macro
> so that it selects the active range for each day. Here is the
> relevant
> portion of the macro:
>
> Selection.AutoFilter Field:=8, Criteria1:="Ad"
> Range("L87").Select
> ActiveCell.FormulaR1C1 = "=TODAY()"
> Selection.Copy
> Range("L307:L5100").Select
> ActiveSheet.Paste
>
> I'm a complete novice at macros, so if anyone has any ideas for a
> code
> that would work, please help!
>
> Thanks,
> Jill


--

Dave Peterson
 
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
Autofilter Macro robot Microsoft Excel Programming 5 24th Sep 2009 11:09 AM
Macro, AutoFilter... Aline Microsoft Excel Misc 1 27th Jul 2008 12:27 AM
Autofilter Macro Help =?Utf-8?B?Um9uQg==?= Microsoft Excel Misc 1 30th Dec 2004 01:34 AM
AutoFilter / Macro =?Utf-8?B?TGlzYQ==?= Microsoft Excel Worksheet Functions 2 16th May 2004 05:06 PM
macro autofilter brian Microsoft Excel Worksheet Functions 0 7th Jan 2004 06:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:46 AM.