ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete selected sheet (https://www.excelbanter.com/excel-programming/364065-delete-selected-sheet.html)

cyzax7 via OfficeKB.com

Delete selected sheet
 
Hi there,

I have created a check box to delete certain sheet (which is called by ref) )
in my mainsheet called "Home". So that when user check the box, it will
delete the selected sheet. This is what I've done so far... Can some one
correct me..???



Const MainSheet = "Home"

/-----------------------------------------------------------------------------
--------------------------------------/
Sub InitializeValues()

With Worksheets(MainSheet) 'check for
all user inputs

ClearResultsSheet_checked = .ClearResultsSheetCheckBox1.Value

End With
End Sub

/-----------------------------------------------------------------------------
------------------------------------/
Sub ClearSheet(ByRef spectype As String)
'just to clear the old Results Sheet before putting any new data
in

Dim strname As String

strname = spectype & " Results"

Worksheets(strname).Activate

'Worksheets(SheetName).Activate
Cells.Select
Selection.Delete
Range("A").Select

End Sub

/-----------------------------------------------------------------------------
--------------------------------/

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200606/1

Leith Ross[_573_]

Delete selected sheet
 

Hello cyzax7,

Try this...

Sub ClearSheet(ByRef spectype As String)
'just to clear the old Results Sheet before putting any new data
in

Dim strname As String

strname = spectype & " Results"

With Worksheets(strname)
UsedRange.ClearContents
Range("A").Select
End With

End Sub

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=551257



All times are GMT +1. The time now is 12:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com