Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 469
Default works and doesn't work

used auto filter to build a macro works fine then copied it over and edited
for next sheet 8 times works all except 2 sheets. can see no diff except edit
I did. Here is one that works and one that doesn't five works six doesn't
six produces header no data. modules 1-5 work fine 6 out 7ok 8 out 9 ok all
copied from same. Hoping someone can see what is wrong. Can start over and
build 6&8 over if needed. For my knowledge would like to know what is wrong.
Thanks to All
Sub Five()
' Two Macro
' Macro recorded 9/28/2007 by Curtiss A. Greer
Range("D4").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="5 Float"
Range("A1:N104").Select
Selection.Copy
Sheets("5").Select
Range("A1").Select
ActiveSheet.Paste
Columns("E:L").Select
Columns("A:A").ColumnWidth = 3.57
Columns("B:B").ColumnWidth = 11.29
Columns("C:C").ColumnWidth = 22.43
Columns("D:D").ColumnWidth = 15.14
Application.CutCopyMode = False
Selection.ClearContents
Range("G14").Select
Sheets("Data").Select
Range("E20").Select
Selection.AutoFilter
End Sub
Sub Six()
' Two Macro
' Macro recorded 9/28/2007 by Curtiss A. Greer
Range("D4").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="6 March Mil"
Range("A1:N104").Select
Selection.Copy
Sheets("6").Select
Range("A1").Select
ActiveSheet.Paste
Columns("E:L").Select
Columns("A:A").ColumnWidth = 3.57
Columns("B:B").ColumnWidth = 11.29
Columns("C:C").ColumnWidth = 22.43
Columns("D:D").ColumnWidth = 15.14
Application.CutCopyMode = False
Selection.ClearContents
Range("G14").Select
Sheets("Data").Select
Range("E20").Select
Selection.AutoFilter
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default works and doesn't work

Since the two procedures appear to be identical except for the selection
criteria, the problem must lie in the criteria versus the data base. That
is, it is not finding the criteria you have specified. You can walk through
the procedure one step at a time to see if it is doing what you expect and
identify the step where it does not do what you expect. Then you can more
easily analyze why it is not doing it. Below is a cleaned up version of your
code, that removes all the unnecessary "selects". I did not test it so if
you decide to use it, you should first test it on copies of your files.

Sub Five()
' Two Macro
' Macro recorded 9/28/2007 by Curtiss A. Greer
Range("D4").AutoFilter Field:=1, Criteria1:="5 Float"
Range("A1:N104").Copy Sheets("5").Range("A1")
Columns("A:A").ColumnWidth = 3.57
Columns("B:B").ColumnWidth = 11.29
Columns("C:C").ColumnWidth = 22.43
Columns("D:D").ColumnWidth = 15.14
Application.CutCopyMode = False
Columns("E:L").ClearContents
Range("G14").Select
Sheets("Data").Range("E20").AutoFilter
End Sub
Sub Six()
' Two Macro
' Macro recorded 9/28/2007 by Curtiss A. Greer
Range("D4").AutoFilter Field:=1, Criteria1:="6 March Mil"
Range("A1:N104").Copy Sheets("6").Range("A1")
Columns("A:A").ColumnWidth = 3.57
Columns("B:B").ColumnWidth = 11.29
Columns("C:C").ColumnWidth = 22.43
Columns("D:D").ColumnWidth = 15.14
Application.CutCopyMode = False
Columns("E:L").ClearContents
Range("G14").Select
Sheets("Data").Range("E20").AutoFilter
End Sub



"Curt" wrote:

used auto filter to build a macro works fine then copied it over and edited
for next sheet 8 times works all except 2 sheets. can see no diff except edit
I did. Here is one that works and one that doesn't five works six doesn't
six produces header no data. modules 1-5 work fine 6 out 7ok 8 out 9 ok all
copied from same. Hoping someone can see what is wrong. Can start over and
build 6&8 over if needed. For my knowledge would like to know what is wrong.
Thanks to All
Sub Five()
' Two Macro
' Macro recorded 9/28/2007 by Curtiss A. Greer
Range("D4").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="5 Float"
Range("A1:N104").Select
Selection.Copy
Sheets("5").Select
Range("A1").Select
ActiveSheet.Paste
Columns("E:L").Select
Columns("A:A").ColumnWidth = 3.57
Columns("B:B").ColumnWidth = 11.29
Columns("C:C").ColumnWidth = 22.43
Columns("D:D").ColumnWidth = 15.14
Application.CutCopyMode = False
Selection.ClearContents
Range("G14").Select
Sheets("Data").Select
Range("E20").Select
Selection.AutoFilter
End Sub
Sub Six()
' Two Macro
' Macro recorded 9/28/2007 by Curtiss A. Greer
Range("D4").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="6 March Mil"
Range("A1:N104").Select
Selection.Copy
Sheets("6").Select
Range("A1").Select
ActiveSheet.Paste
Columns("E:L").Select
Columns("A:A").ColumnWidth = 3.57
Columns("B:B").ColumnWidth = 11.29
Columns("C:C").ColumnWidth = 22.43
Columns("D:D").ColumnWidth = 15.14
Application.CutCopyMode = False
Selection.ClearContents
Range("G14").Select
Sheets("Data").Select
Range("E20").Select
Selection.AutoFilter
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 469
Default works and doesn't work

I did find the problem. I went back to database and copied and pasted the
"criteria" I checked for spaces etc and when pasteing it all worked.
Thanks for the clean up.
Your assistance greatly appreciated.

"JLGWhiz" wrote:

Since the two procedures appear to be identical except for the selection
criteria, the problem must lie in the criteria versus the data base. That
is, it is not finding the criteria you have specified. You can walk through
the procedure one step at a time to see if it is doing what you expect and
identify the step where it does not do what you expect. Then you can more
easily analyze why it is not doing it. Below is a cleaned up version of your
code, that removes all the unnecessary "selects". I did not test it so if
you decide to use it, you should first test it on copies of your files.

Sub Five()
' Two Macro
' Macro recorded 9/28/2007 by Curtiss A. Greer
Range("D4").AutoFilter Field:=1, Criteria1:="5 Float"
Range("A1:N104").Copy Sheets("5").Range("A1")
Columns("A:A").ColumnWidth = 3.57
Columns("B:B").ColumnWidth = 11.29
Columns("C:C").ColumnWidth = 22.43
Columns("D:D").ColumnWidth = 15.14
Application.CutCopyMode = False
Columns("E:L").ClearContents
Range("G14").Select
Sheets("Data").Range("E20").AutoFilter
End Sub
Sub Six()
' Two Macro
' Macro recorded 9/28/2007 by Curtiss A. Greer
Range("D4").AutoFilter Field:=1, Criteria1:="6 March Mil"
Range("A1:N104").Copy Sheets("6").Range("A1")
Columns("A:A").ColumnWidth = 3.57
Columns("B:B").ColumnWidth = 11.29
Columns("C:C").ColumnWidth = 22.43
Columns("D:D").ColumnWidth = 15.14
Application.CutCopyMode = False
Columns("E:L").ClearContents
Range("G14").Select
Sheets("Data").Range("E20").AutoFilter
End Sub



"Curt" wrote:

used auto filter to build a macro works fine then copied it over and edited
for next sheet 8 times works all except 2 sheets. can see no diff except edit
I did. Here is one that works and one that doesn't five works six doesn't
six produces header no data. modules 1-5 work fine 6 out 7ok 8 out 9 ok all
copied from same. Hoping someone can see what is wrong. Can start over and
build 6&8 over if needed. For my knowledge would like to know what is wrong.
Thanks to All
Sub Five()
' Two Macro
' Macro recorded 9/28/2007 by Curtiss A. Greer
Range("D4").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="5 Float"
Range("A1:N104").Select
Selection.Copy
Sheets("5").Select
Range("A1").Select
ActiveSheet.Paste
Columns("E:L").Select
Columns("A:A").ColumnWidth = 3.57
Columns("B:B").ColumnWidth = 11.29
Columns("C:C").ColumnWidth = 22.43
Columns("D:D").ColumnWidth = 15.14
Application.CutCopyMode = False
Selection.ClearContents
Range("G14").Select
Sheets("Data").Select
Range("E20").Select
Selection.AutoFilter
End Sub
Sub Six()
' Two Macro
' Macro recorded 9/28/2007 by Curtiss A. Greer
Range("D4").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="6 March Mil"
Range("A1:N104").Select
Selection.Copy
Sheets("6").Select
Range("A1").Select
ActiveSheet.Paste
Columns("E:L").Select
Columns("A:A").ColumnWidth = 3.57
Columns("B:B").ColumnWidth = 11.29
Columns("C:C").ColumnWidth = 22.43
Columns("D:D").ColumnWidth = 15.14
Application.CutCopyMode = False
Selection.ClearContents
Range("G14").Select
Sheets("Data").Select
Range("E20").Select
Selection.AutoFilter
End Sub

Reply
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
Hyperlink formula works, and then doesn't work silent_tiger[_2_] Excel Discussion (Misc queries) 2 May 25th 09 12:47 AM
Code not work Take same action on all wkshts or selected works Rookie_User Excel Programming 0 January 24th 07 07:01 AM
macro doesn't work on Excel for the mac but works on Windows XL?? Dave F Excel Programming 3 December 27th 06 08:07 PM
it works, it doesn work, its works....and so on. Naz Excel Programming 6 September 30th 05 01:52 PM
How can I get EXCEL formulas to work in Works? MJBPPG Excel Worksheet Functions 0 March 12th 05 07:31 PM


All times are GMT +1. The time now is 01:34 PM.

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

About Us

"It's about Microsoft Excel"