Hi guys,
I'm trying to copy content of one sheet to newly created sheet. The copy&paste code I created using "record macro" option.
Code below fails on the line "Sheets(wsName).Select" with error 400. (select method of class Range failed)
Could you please write what's wrong with that?
Thanks
![]()
wsName = Sheets("Sheet1").Range("I7") Dim WS As Worksheet If WorksheetExists(wsName) Then Sheets(wsName).Delete Set WS = Sheets.Add(After:=Sheets(Worksheets.Count)) WS.Name = wsName Else Set WS = Sheets.Add(After:=Sheets(Worksheets.Count)) WS.Name = wsName End If Sheets("Sheet1").Range("A1:J10").Select Range("J10").Activate Selection.Copy ' HAVE PROBLEM HERE - ERROR 400 Sheets(wsName).Select Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False ActiveSheet.Paste
Bookmarks