I am trying to copy filtered data from a .xlsm workbook (an image, headings, filtered data) to a new .xlsx workbook. I found some code that I have modified which copies the data in the active worksheet to a new workbook allowing the user to enter their own title and save as. The issue is that the code copies all data, not just the filtered data. Could anyone assist with code that copies only the filtered data? If there is a better way to write the code, that would be appreciated.
Code:
[COLOR=#222222][FONT=Verdana][FONT=Verdana]Sub GenerateSeparateFile()[/FONT][/FONT][/COLOR]
[COLOR=#222222][FONT=Verdana][FONT=Verdana] Dim ThisFile As String
Dim NewFile As String
Dim NewFileType As String
ThisFile = ThisWorkbook.FullName
NewFileType = "Excel 2016 (*.xlsx), .*xlsx"
NewFile = Application.GetSaveAsFilename(InitialFileName:=NewFileName, FileFilter:=NewFileType)
ActiveWorkbook.Sheets(2).Copy
ActiveWorkbook.SaveAs Filename:=NewFile, FileFormat:=51
ThisWorkbook.Sheets(2).Range("A1:H5000").Copy
ActiveWorkbook.Sheets(1).Range("A1:H5000").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False
Application.ScreenUpdating = True[/FONT][/FONT][/COLOR]
[COLOR=#222222][FONT=Verdana][FONT=Verdana]End Sub[/FONT][/FONT][/COLOR]