2

Trying to add a worksheet and name it "For Export" Throwing error on the set WS line, "Method 'Add' of object 'Sheets' failed" Thanks in advance.

Dim WS As Worksheet
'Add sheet named "For Export"
Set WS = Sheets.Add(After:=Sheets(Worksheets.Count))
WS.Name = "For Export"
Sheets("For Export").Select
5
  • which excel are u using? Commented Jan 23, 2018 at 21:54
  • Hm...does Set ws = Worksheets.Add(after:=Sheets(Worksheets.Count)) work? Commented Jan 23, 2018 at 21:55
  • 1
    Your code works verbatim for me. I am using Excel 2016 Commented Jan 23, 2018 at 22:00
  • I changed to set ws =Worksheet.add, and the error changed to "object required" Commented Jan 23, 2018 at 22:02
  • I'm using Excel 2016 Commented Jan 23, 2018 at 22:06

1 Answer 1

1

Try this VBA Macro:

 Sub Add()
Set wb = Application.ActiveWorkbook
wb.Sheets.Add(After:=wb.Sheets(wb.Sheets.Count)).Name =  "For Export"
End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.