I have to copy every sheets only with actual data range.
I tried two codes. One is for creating new workbooks, worksheets and renaming sheets. Another is for copying actual data range. Both works fine. While I tried to combine these two codes, it doesn't work anymore.
Sub dural()
Dim b1 As Workbook, b2 As Workbook
Set b2 = ActiveWorkbook
Set b1 = Workbooks.Add
For Each sh2 In b2.Sheets
Set sh1 = b1.Sheets.Add
sh1.Name = sh2.Name
' Show hide Columns and Rows
sh2.Columns.EntireColumn.Hidden = False
Rows.EntireRow.Hidden = False
' Unfilter
If sh2.FilterMode = True Then
sh2.ShowAllData
End If
' Copy and Paste
sh2.Range("A1").Resize(Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row, _
Cells.Find(What:="*", SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Column).Copy _
sh1.Range("A1")
Next sh2
End Sub
It is giving run time error. It is because of the codes under Copy and Paste comment.