Delete Sheets

J

Jahsonn

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
 
F

Frank Kabel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Merge Sheets 2
Calling a module from another module 5
Copy from fixed range does not work 6
Last row 1
VBA - Importing Sheets 18
Import Worksheets and "Overright" 9
ERROR: subscript out of range 6
Copy - Paste 5

Top