By kpmsivaprakasam2003 on Saturday, 04 December 2021
Posted in Excel
Replies 1
Likes 0
Views 6.1K
Votes 0
Hi,

I am working Excel 2013,

I need the Autofilter "#N/A" in the "F" column, if filter the "#N/A" no data with the heading, "Goto 0:" code does...

but, my code not working, goto 0:

Sub testsss()
'Filter Insert and #N/A Copy and Paste
'VBA – Turn Off Autofilter From Code
If ActiveSheet.AutoFilterMode Then
ActiveSheet.AutoFilterMode = False 'ActiveSheet.Range("A1").AutoFilter ---> Turn On Autofilter
End If

'Auto Filter 2nd Column Blank Cells filter
Dim LastRow As Long
LastRow = Range("B" & Rows.Count).End(xlUp).Row

On Error Resume Next 'if filter then no data go next
ActiveSheet.Range("$A$1:$F" & LastRow).AutoFilter Field:=6, Criteria1:="#N/A" 'Not Applicable Cells filter then select visible cells
Range("$A$2:$F" & LastRow).SpecialCells(xlCellTypeVisible).Select

'Stop copy paste if the filtered range has no data
If Range("A1:F" & LastRow).SpecialCells(xlCellTypeVisible).Count > 1 Then
Range("$B$2:$D" & LastRow).SpecialCells(xlCellTypeVisible).Select
Selection.Copy
'Do Something Code.........
Application.CutCopyMode = False
Else
ActiveSheet.AutoFilterMode = False
GoTo 0:
End If

'Do Something Code.........

0:
End Sub


Kindly help me, thanks for advance
  Stop copy paste if the filtered range has no data.zip
  Stop copy paste if the filtered range has no data.zip
Hi kpmsivaprakasam2003,

Sorry I couldn't understand you. What do you mean by this: "I need the Autofilter "#N/A" in the "F" column, if filter the "#N/A" no data with the heading, "Goto 0:" code does..."?

I look forward to hearing from you soon.

Amanda
·
2 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post