|
-
Jul 2nd, 2004, 07:46 AM
#1
Thread Starter
PowerPoster
Delete Excel.Worksheet without stupid prompt?
Hi,
Lookin to delete sheets in the Excel.Workbook without the user being prompted fro EVERY sheet I delete in code.
ie..
VB Code:
Dim sheet As Excel.Worksheet
Set sheet = New Excel.Worksheet
sheet.Delete ' <-- This always prompts the user!! ARGH!
Dave
-
Jul 2nd, 2004, 08:03 AM
#2
Re: Delete Excel.Worksheet without stupid prompt?
VB Code:
Dim sheet As Excel.Worksheet
Set sheet = New Excel.Worksheet
Application.DisplayAlerts = False
sheet.Delete
Application.DisplayAlerts = True
-
Jul 2nd, 2004, 08:10 AM
#3
Thread Starter
PowerPoster
A) How the heck did you know that?
B) WOO-HOO!!!!!!!
-
Jul 2nd, 2004, 08:11 AM
#4
VB Code:
dim blnAlertStatus as boolean
'---- Turn off alerts
blnAlertStatus = Application.DisplayAlerts
Application.DisplayAlerts = false
'---- do processing
'---- Turn on alerts
Application.DisplayAlerts = blnDisplayAlerts
There is another to freeze the sheet display, can't find it tho.
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jul 2nd, 2004, 08:22 AM
#5
That would be:
VB Code:
Application.ScreenUpdating = False
'do stuff
Application.ScreenUpdating = True
It is a bit strange when you arent showing something else (and Excel is visible), as it looks like Excel has crashed. If your code crashes before you reset it then Excel can stay like it the next time it is opened too
-
Jan 11th, 2014, 07:00 AM
#6
Lively Member
Re: Delete Excel.Worksheet without stupid prompt?
i am having total of 4 sheets of which sheet 1 & sheet 4 r compulsory
i am using datatable to fill the sheet with data
if dt1.rows.count<>0
-- write data to excel cells
else
oWB1.Application.DisplayAlerts = False
oWB1.Sheets("ABC").Delete
oWB1.Application.DisplayAlerts = True
end if
if dt2.rows.count<>0
-- write data to excel cells
else
oWB1.Application.DisplayAlerts = False
oWB1.Sheets("XYZ").Delete
oWB1.Application.DisplayAlerts = True
end if
i get error when it goes to else part of dt1 ie on the line
oWB1.Sheets("ABC").Delete
but if dt2 count is 0 the else part gets executed sucessfully ie the sheet 3 gets deleted
-
Jan 11th, 2014, 09:22 AM
#7
Re: Delete Excel.Worksheet without stupid prompt?
what is the error at that line?
-
Jan 12th, 2014, 11:58 PM
#8
Lively Member
Re: Delete Excel.Worksheet without stupid prompt?
 Originally Posted by vbfbryce
what is the error at that line?
error
Public member 'Worksheets' on type 'Worksheet' not found
-
Jan 13th, 2014, 07:47 AM
#9
Re: Delete Excel.Worksheet without stupid prompt?
Does worksheet "ABC" exist in that workbook?
-
Jan 14th, 2014, 01:14 AM
#10
Lively Member
Re: Delete Excel.Worksheet without stupid prompt?
-
Jan 14th, 2014, 07:58 AM
#11
Re: Delete Excel.Worksheet without stupid prompt?
Can you post the whole code, including the variable definitions?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|