LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 76
Default Macro - Whats wrong?

On 1 Sep, 10:43, NPell wrote:
On 29 Aug, 18:03, "Bernie Deitrick" <deitbe @ consumer dot org wrote:





Try it this way:


Sub TryNow()
Dim myA As Variant
Dim myV As Variant


myA = Array("Criteria 1", "Criteria 2")


For Each myV In myA
Sheets("Data").Range("A:J").AutoFilter Field:=10, Criteria1:=myV
Intersect(Range("A1").CurrentRegion, Range("A2:I" & Rows.Count)) _
* *.SpecialCells(xlCellTypeVisible).Copy _
Sheets(myV).Cells(Rows.Count, "A").End(xlUp)(2)
Sheets("Data").Cells.AutoFilter
Next myV
End Sub


--
HTH,
Bernie
MS Excel MVP


"NPell" wrote in message


....


Whatrs wrong with this??


I either get an error saying no data, or can not be used with multiple
selection.


* *Sheets("Data").Select
* *Selection.AutoFilter Field:=10, Criteria1:="Criteria 1"
* *Range("A1").Offset(1, 0).Select
* *Range("A1:I1").Offset(1, 0).Select
* *Range(Selection, Selection.End(xlDown)).Select
* *Selection.SpecialCells(xlCellTypeConstants, xlNumbers +
xlTextValues).Select
* *On Error GoTo ErrorTrap1
* *Selection.Copy
* *lastrow = Sheets("Criteria 1").Cells(Rows.Count,
"A").End(xlUp).Row
* *Sheets("Criteria 1").Range("A" & lastrow + 1).PasteSpecial
ErrorTrap1:
* *Application.CutCopyMode = False
* *Range("A1").Select


* *Sheets("Data").Select
* *Selection.AutoFilter Field:=10, Criteria1:="Criteria 2"
* *Range("A1").Offset(1, 0).Select
* *Range("A1:I1").Offset(1, 0).Select
* *Range(Selection, Selection.End(xlDown)).Select
* *Selection.SpecialCells(xlCellTypeConstants, xlNumbers +
xlTextValues).Select
* *On Error GoTo ErrorTrap2
* *Selection.Copy
* *lastrow = Sheets("Criteria 2").Cells(Rows.Count,
"A").End(xlUp).Row
* *Sheets("Criteria 2").Range("A" & lastrow + 1).PasteSpecial
ErrorTrap2:
* *Application.CutCopyMode = False
* *Range("A1").Select


Any advice?- Hide quoted text -


- Show quoted text -


I got "Error - No Cells Were Found" on Criteria 1, as it is blank.- Hide quoted text -

- Show quoted text -


Added an "On Error Resume Next". All sorted.
Thanks very much Bernie mate.


 
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
whats wrong with this? brownti via OfficeKB.com Excel Discussion (Misc queries) 10 February 12th 07 02:39 PM
Whats wrong with this OR formula? Mark Excel Worksheet Functions 4 October 23rd 06 07:16 PM
Whats wrong with this macro please Mike Excel Discussion (Misc queries) 6 February 5th 06 09:31 PM
Whats wrong with this? LucasBuck Excel Discussion (Misc queries) 3 January 12th 06 08:15 PM
Whats Wrong with this?? drvortex Excel Worksheet Functions 1 October 30th 04 06:48 PM


All times are GMT +1. The time now is 08:54 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"