I am trying to filter a tab in excel for non blank cells, copy those cells, and paste the copied data in a txt file. I then need the filter applied on the tab in excel to be removed. When I try to input the clear sub in the TEST sub, the copy and paste to the TXT file is blank. I would like to only have one macro instead of a separate one to remove the excel filter. Thank you!
Sub TEST()
Dim copysheet As Worksheet
Dim TextFile As Integer
Set copysheet = ActiveWorkbook.Sheets("temptotext")
Sheets("temptotext").Select
Rows("1:1").Select
Selection.AutoFilter
copysheet.Range("$A:$A").AutoFilter Field:=1, Criteria1:="<>"
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Shell "notepad.exe", vbNormalFocus
SendKeys "^v"
End Sub
Sub clear()
Dim copysheet As Worksheet
Set copysheet = Sheets("temptotext")
copysheet.Select
Cells.AutoFilter
End Sub