Re: running code

From: Nick Hodge (nick_hodgeTAKETHISOUT_at_zen.co.uk.ANDTHIS)
Date: 03/12/05


Date: Sat, 12 Mar 2005 15:14:45 -0000

Mark

Put it in a standard code module and assign the macro to a command button by
selecting one from the forms toolbar, right clicking and selecting 'Assign
macro'. The way you have it set up currently it is in the 'ThisWorkbook'
class module and will run by the Open event (Each time the workbook is first
opened)

For explanation of the different modules, check here

http://www.nickhodge.co.uk/vba/vbaimplement.htm

-- 
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
nick_hodgeTAKETHISOUT@zen.co.uk.ANDTHIS
"mark" <anonymous@discussions.microsoft.com> wrote in message 
news:783601c52715$253edb40$a601280a@phx.gbl...
>I have the following code in my workbook, how can I use a
> command button to run this.
> Private Sub Workbook_Open()
> Dim wb As Workbook
> 'copy all sheets
> Worksheets.Copy
> Set wb = ActiveWorkbook
> Application.DisplayAlerts = False
> 'delete the sheets you want
> wb.Sheets(Array("Suspense", "RCA exc RIM", "Operations
> summary", "RCA incl RIM", "First Qtr", "Second
> Qtr", "Third Qtr", "Fourth Qtr")).Delete
> Application.DisplayAlerts = True
>
> End Sub
>
>
> any help please
>
> Mark