PC Review


Reply
Thread Tools Rate Thread

Copying data with a macro using autofilter

 
 
=?Utf-8?B?cm1jb21wdXRl?=
Guest
Posts: n/a
 
      14th Jul 2007
I set up a few columns of data with an autofilter. The user selects only 1
row at a time with the auto filter. I want to set up a macro to copy this
row to another area of the worksheet for graphing. When All is selected by
the filter, the first record is row 5. I can set up a macro to copy row 5 to
another location for graphing. However, when a user selects any other row,
row 5 of the spreadsheet is now replaced by that row and the macro does not
work. Is there a way to determine what row the user selects by a filter, and
copy that row to another area of the spreadsheet ?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      14th Jul 2007
Study this code for insights:

http://www.rondebruin.nl/copy5.htm


--
Regards,
Tom Ogilvy


"rmcompute" wrote:

> I set up a few columns of data with an autofilter. The user selects only 1
> row at a time with the auto filter. I want to set up a macro to copy this
> row to another area of the worksheet for graphing. When All is selected by
> the filter, the first record is row 5. I can set up a macro to copy row 5 to
> another location for graphing. However, when a user selects any other row,
> row 5 of the spreadsheet is now replaced by that row and the macro does not
> work. Is there a way to determine what row the user selects by a filter, and
> copy that row to another area of the spreadsheet ?

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      14th Jul 2007
On additional bit, if you copy the entire range of data that has a filter
applied, only the visible rows are copied. This is the default behavior.

If you step down one row so the header is not included, then you only will
copy your single row.

ActiveSheet.AutFilter.Range includes the header

With ActiveSheet.Autofilter.Range
set r = .offset(1,0).Resize(.rows.count-1)
End with

r should be your row.

--
Regards,
Tom Ogilvy


"rmcompute" wrote:

> I set up a few columns of data with an autofilter. The user selects only 1
> row at a time with the auto filter. I want to set up a macro to copy this
> row to another area of the worksheet for graphing. When All is selected by
> the filter, the first record is row 5. I can set up a macro to copy row 5 to
> another location for graphing. However, when a user selects any other row,
> row 5 of the spreadsheet is now replaced by that row and the macro does not
> work. Is there a way to determine what row the user selects by a filter, and
> copy that row to another area of the spreadsheet ?

 
Reply With Quote
 
=?Utf-8?B?cm1jb21wdXRl?=
Guest
Posts: n/a
 
      15th Jul 2007
It worked. Thank you.

"Tom Ogilvy" wrote:

> On additional bit, if you copy the entire range of data that has a filter
> applied, only the visible rows are copied. This is the default behavior.
>
> If you step down one row so the header is not included, then you only will
> copy your single row.
>
> ActiveSheet.AutFilter.Range includes the header
>
> With ActiveSheet.Autofilter.Range
> set r = .offset(1,0).Resize(.rows.count-1)
> End with
>
> r should be your row.
>
> --
> Regards,
> Tom Ogilvy
>
>
> "rmcompute" wrote:
>
> > I set up a few columns of data with an autofilter. The user selects only 1
> > row at a time with the auto filter. I want to set up a macro to copy this
> > row to another area of the worksheet for graphing. When All is selected by
> > the filter, the first record is row 5. I can set up a macro to copy row 5 to
> > another location for graphing. However, when a user selects any other row,
> > row 5 of the spreadsheet is now replaced by that row and the macro does not
> > work. Is there a way to determine what row the user selects by a filter, and
> > copy that row to another area of the spreadsheet ?

 
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
Macro / Autofilter / Show All Data CousinExcel Microsoft Excel Misc 3 17th Feb 2010 01:28 PM
A better Macro for Copying Data drinese18 Microsoft Excel Programming 2 8th Apr 2008 07:20 PM
How can i Change Autofilter data from top till bottom in macro =?Utf-8?B?VmlqYXkgS290aWFu?= Microsoft Excel Misc 0 5th Sep 2006 09:10 AM
Macro for copying data =?Utf-8?B?c2phYmxvbnNraQ==?= Microsoft Access Macros 2 29th Jul 2006 05:09 PM
Macro for copying data Roger Bell Microsoft Access 7 20th Nov 2004 04:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:51 AM.