LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel Autofilter Copy and Paste with Changing Values

I have used a macro written by Ron de Bruin entitled Copy5 that uses
Autofilter to find, copy, and paste rows from one worksheet to another.

My search criteria are called out as follows:

My_Range.AutoFilter Field:=2, Criteria1:="=" &
Worksheets("Calculations").Range("A16").Value
My_Range.AutoFilter Field:=3, Criteria1:="=" &
Worksheets("InputPage").Range("A13").Value
My_Range.AutoFilter Field:=4, Criteria1:="=" &
Worksheets("InputPage").Range("B2").Value
My_Range.AutoFilter Field:=9, Criteria1:="=" &
Worksheets("InputPage").Range("C14").Value

This is my paste information, in this case:
Set My_Range = Worksheets("Options").Range("A1:O" &
LastRow(Worksheets("Options")))
My_Range.Parent.Select
DestSh = Worksheets("InputPage")

With My_Range.Parent.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 10).Resize(.Rows.count - 1, 5) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then
rng.Copy
With DestSh.Range("D14")
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
Application.CutCopyMode = False
End With
End If
End With

The single-cell ranges for the first three criteria are always static.

I have two questions, as follows:
1) The 4th listed Criteria for Field9 refers to cell C14 on the input page.
The final result pastes into Row 14 of that page. Every value for every row
in Column C is different for the extent of the worksheet, and each of them
needs to be filtered by this subroutine. I am currently running this sub
separately for EVERY row on the worksheet (which is quite long) and having
each sub call out the next. This is cumbersome, as the filter switches
repeatedly between the Options page and the InputPage. There must be a
way to ask the filter to look at the value in the C column of each row and
paste the result in the corresponding row starting in the D column in a
specified range of rows, so that I can run one filter to do the whole job,
instead of running a separate sub for each line. HELP!!!!
2) Far less important: Id like, for instance, for the 3rd listed Criteria
for Field 4 to match to what is in B2 of the InputPage, but, if the
corresponding value in Field 4 is blank, Id like it to still take that row.
How do I do this without running a second subroutine? Maybe an OR in there
somewhere?

Please, I beg of you.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Of Values After A Copy And Paste Special: Why ? Bob[_19_] Excel Discussion (Misc queries) 1 March 15th 10 11:44 PM
Prevent changing size when copy&paste into another Excel Worksheet Michelle Excel Worksheet Functions 0 June 26th 06 04:30 PM
Copy/Paste in Autofilter honyacker Excel Discussion (Misc queries) 2 January 12th 06 02:38 PM
Autofilter and Copy and Paste Shawn Excel Programming 1 March 4th 05 05:43 PM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM


All times are GMT +1. The time now is 06:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"