A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Private sub



 
 
Thread Tools Display Modes
  #1  
Old April 6th, 2005, 02:15 PM
Mark
external usenet poster
 
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  
Old April 6th, 2005, 02:26 PM
Mark
external usenet poster
 
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  
Old April 6th, 2005, 03:23 PM
JE McGimpsey
external usenet poster
 
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  
Old April 6th, 2005, 03:36 PM
mark
external usenet poster
 
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.

.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OLE Object- the real question Michelle Using Forms 18 February 28th, 2005 04:04 AM
Outlook should allow me to specify text instead of PRIVATE APPOIN. jretzer Calendar 0 January 4th, 2005 03:23 PM
Outlook should let me set "PRIVATE" automatically Bauerchick Calendar 1 October 7th, 2004 02:35 PM
Troubleshoot the SendObject method Nikky_Pickles General Discussion 1 August 30th, 2004 07:40 AM
Rich Text Spell Check Stephen Lebans General Discussion 0 July 27th, 2004 01:03 AM


All times are GMT +1. The time now is 11:53 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.