#1   Report Post  
Mark
 
Posts: n/a
Default Code

The following code works well, however how can I change
this to run with a command button.
Also is there any way I could delete some columns from
the sheets as well.

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

Thanks

Mark

  #2   Report Post  
Ron de Bruin
 
Posts: n/a
Default

Hi Mark

This example will delete column A and B in each sheet

Alt-F11
InsertModule from the menubar
paste the sub in there
Alt-Q to go back to Excel

If you use Alt-F8 you get a list of your macro's
Select "test" and press Run

Or right click on a commandbar and click on Forms
Add a button on your sheet and assign the macro to it

Sub test()
Dim wb As Workbook
Dim sh As Worksheet
Worksheets.Copy
Set wb = ActiveWorkbook
Application.DisplayAlerts = False
wb.Sheets(Array("Suspense", "RCA exc RIM", "Operations summary", "RCA incl RIM", "First Qtr", "Second Qtr", "Third Qtr", "Fourth
Qtr")).Delete
Application.DisplayAlerts = True

For Each sh In wb.Worksheets
sh.Columns("A:B").EntireColumn.Delete
Next
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Mark" wrote in message ...
The following code works well, however how can I change
this to run with a command button.
Also is there any way I could delete some columns from
the sheets as well.

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

Thanks

Mark



  #3   Report Post  
mark
 
Posts: n/a
Default

Soz i have posted the first part of this query twice.
i now have the command button working.
so can anyone help with the second part ie deleting
colums. Is there anyway you can stop the command button
from transfering to the new sheet.

thanks for this

mark.
-----Original Message-----
The following code works well, however how can I change
this to run with a command button.
Also is there any way I could delete some columns from
the sheets as well.

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

Thanks

Mark

.

  #4   Report Post  
mark
 
Posts: n/a
Default

Soz i have posted the first part of this query twice.
i now have the command button working.
so can anyone help with the second part ie deleting
colums. Is there anyway you can stop the command button
from transfering to the new sheet.

thanks for this

mark.
-----Original Message-----
The following code works well, however how can I change
this to run with a command button.
Also is there any way I could delete some columns from
the sheets as well.

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

Thanks

Mark

.

  #5   Report Post  
Mark
 
Posts: n/a
Default

this work great thanks for your help.

-----Original Message-----
Hi Mark

This example will delete column A and B in each sheet

Alt-F11
InsertModule from the menubar
paste the sub in there
Alt-Q to go back to Excel

If you use Alt-F8 you get a list of your macro's
Select "test" and press Run

Or right click on a commandbar and click on Forms
Add a button on your sheet and assign the macro to it

Sub test()
Dim wb As Workbook
Dim sh As Worksheet
Worksheets.Copy
Set wb = ActiveWorkbook
Application.DisplayAlerts = False
wb.Sheets(Array("Suspense", "RCA exc

RIM", "Operations summary", "RCA incl RIM", "First
Qtr", "Second Qtr", "Third Qtr", "Fourth
Qtr")).Delete
Application.DisplayAlerts = True

For Each sh In wb.Worksheets
sh.Columns("A:B").EntireColumn.Delete
Next
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Mark" wrote in

message ...
The following code works well, however how can I change
this to run with a command button.
Also is there any way I could delete some columns from
the sheets as well.

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

Thanks

Mark



.

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
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 7 March 7th 05 06:29 PM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 4th 05 10:50 AM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 3rd 05 03:40 PM
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 0 February 28th 05 06:26 PM
Command Button VBA code Dave Peterson Excel Discussion (Misc queries) 2 January 25th 05 11:28 PM


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