ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Sheets (https://www.excelbanter.com/excel-programming/296280-delete-sheets.html)

Jahsonn

Delete Sheets
 
Hi Experts
The following code should open wb FNAME and then the
Delete sheet who's name is in cell G10 in worksheet
CONTROL. It opens the FNAME sheet but it is not deleting
sheet REMITID.

Can anyone help?

Sub Cleardown_Remit()

RemitID = Worksheets("Control").Range("G10").Value
fname = Worksheets("Control").Range("H10").Value

With Application
..ScreenUpdating = False
..DisplayAlerts = False
End With

Set oWb = Workbooks.Open(fname)
Worksheets(RemitID).Delete
oWb.Close

With Application
..ScreenUpdating = True
..DisplayAlerts = True
End With

End Sub


Frank Kabel

Delete Sheets
 
Hi
try changing the lines
set oWb = Workbooks.Open(fname)
Worksheets(RemitID).Delete
oWb.Close

to
set oWb = Workbooks.Open(fname)
oWb.Worksheets(RemitID).Delete
oWb.save
oWb.Close

-----Original Message-----
Hi Experts
The following code should open wb FNAME and then the
Delete sheet who's name is in cell G10 in worksheet
CONTROL. It opens the FNAME sheet but it is not deleting
sheet REMITID.

Can anyone help?

Sub Cleardown_Remit()

RemitID = Worksheets("Control").Range("G10").Value
fname = Worksheets("Control").Range("H10").Value

With Application
..ScreenUpdating = False
..DisplayAlerts = False
End With

Set oWb = Workbooks.Open(fname)
Worksheets(RemitID).Delete
oWb.Close

With Application
..ScreenUpdating = True
..DisplayAlerts = True
End With

End Sub

.



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

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