Delete Sheets

  • Thread starter Thread starter Jahsonn
  • Start date Start date
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
 
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

Calling a module from another module 5
Merge Sheets 2
Copy from fixed range does not work 6
Last row 1
Worksheet_Change Woes 6
script help! 6
Copy - Paste 5
ERROR: subscript out of range 6

Back
Top