Re: running code

From: JulieD (JulieD_at_hctsReMoVeThIs.net.au)
Date: 03/12/05


Date: Sat, 12 Mar 2005 23:20:32 +0800

Hi

if you have it under Workbook_Open in the ThisWorkbook module the code will
run when you open the workbook - no button needed (ensure that you have your
security settings set to medium - tools / macros / security)

if you want to run it via a button, cut the code from here and keep it in
memory

switch back to the excel work*** - display the control toolbox toolbar
(view / toolbars), click on the command button, click on your work***
where you want it, right mouse click on the command button and choose view
code - now paste your code in there excluding the Private Sub and End Sub
lines

then switch back to the excel work*** - click on the exit design mode icon
on the control toolbox toolbar and test out your button.

Cheers
JulieD

"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


Loading