View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mark[_22_] Mark[_22_] is offline
external usenet poster
 
Posts: 18
Default Form versus Control

This is the macro that runs successfully (it's in Module1):
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 9/14/2003 by Mark Roach
'
Sheets("Sheet2").Select
Worksheets("sheet2").Range("Ak8:BQ20000").Clear
Range("A2:AE99").AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:=Range( _
"AJ2:AJ3"), CopyToRange:=Range("AK8"), Unique:=False
Sheets("sheet3").Select
End Sub

This is the code from Microsoft Excel Objects/Sheet3 that fails to
execute the advanced filter correctly:
Public Sub CommandButton1_Click()
Sheets("Sheet2").Select
Worksheets("sheet2").Range("Ak8:BQ20000").Clear
Range("A2:AE99").AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:=Range( _
"AJ2:AJ3"), CopyToRange:=Range("AK8"), Unique:=False
Sheets("sheet3").Select
End Sub





"Tom Ogilvy" wrote in message ...
That is pretty vague Mark. Can you give an example of specific code that
will run in a button click event, but not in a command button event (which
event - assume click). And what you mean by will not run.

If properly structured and qualified, most code should run in either.

--
Regards,
Tom Ogilvy


Mark wrote in message
om...
Excel has a Control Toolbox and a Forms toolbar.

Both toolbars have a similar icon:
Form has a Button icon for associating a macro,
Control Toolbox has a Control Button that you can copy the code from a
macro into.

I've noticed some code inside a macro will run from the Button but not
the Control Button.

Can anyone help explain this?

Thanks, Mark