#1   Report Post  
Mark
 
Posts: n/a
Default Private sub

I have the following running under a command button.
it works once and then the next time an error appears on
the following line under Sh

For Each Sh In wb.Worksheets



Private Sub CommandButton1_Click()
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

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

Any help please

Mark
  #2   Report Post  
Mark
 
Posts: n/a
Default

Sorry got it working.
i had it running under option explicit, when i removed
this it works fine.

mark
-----Original Message-----
I have the following running under a command button.
it works once and then the next time an error appears on
the following line under Sh

For Each Sh In wb.Worksheets



Private Sub CommandButton1_Click()
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

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

Any help please

Mark
.

  #3   Report Post  
JE McGimpsey
 
Posts: n/a
Default

Removing Option Explicit should never fix the problem you posted. It
affects only the compiling of the project - if it ran once, then it
compiled OK.



In article ,
"Mark" wrote:

Sorry got it working.
i had it running under option explicit, when i removed
this it works fine.

  #4   Report Post  
mark
 
Posts: n/a
Default

I have this worksheet running in a database on lotus
notes and i have had problems with this in the past for
example. when i set up a workbook it work great however
when i move it to the shared database problems start to
occur. i have assumed from this that it must be the lotus
notes database.

thanks for your help

mark.


-----Original Message-----
Removing Option Explicit should never fix the problem

you posted. It
affects only the compiling of the project - if it ran

once, then it
compiled OK.



In article ,
"Mark" wrote:

Sorry got it working.
i had it running under option explicit, when i removed
this it works fine.

.

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
Default view of Excel to 75% Gaurav Excel Discussion (Misc queries) 10 August 4th 07 11:54 PM
Userform - Printing Greg B Excel Worksheet Functions 9 September 16th 05 12:11 AM
Macro to simply bring up the Find dialogue box?? marika1981 Excel Discussion (Misc queries) 14 January 14th 05 11:47 PM
Data Entry Alert in User Form Kev Excel Discussion (Misc queries) 6 January 8th 05 04:01 PM
Check boxes to show/hide Tabs Sridhar Rao Excel Worksheet Functions 1 January 5th 05 04:28 PM


All times are GMT +1. The time now is 09:57 AM.

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"