Macro para eliminar filas con cierto texto

Me surgió una duda para resolver la macro para eliminar filas con dicho texto en este caso convierto el #N/A a texto y quiero eliminar estas filas

Sub pruebas()
'
' Macro1 Macro
'

'
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1), Array(9, 4), Array(10, 4), Array(11, 4), Array(12, 4), Array(13, 1 _
), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array _
(20, 1), Array(21, 1), Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), _
Array(27, 1), Array(28, 1), Array(29, 1), Array(30, 1), Array(31, 1), Array(32, 1), Array( _
33, 1), Array(34, 1), Array(35, 1), Array(36, 1), Array(37, 1), Array(38, 1), Array(39, 1), _
Array(40, 1), Array(41, 1), Array(42, 1), Array(43, 1), Array(44, 1), Array(45, 1)), _
TrailingMinusNumbers:=True
'
Columns("A:A"). EntireColumn. AutoFit
Columns("B:B"). EntireColumn. AutoFit
Columns("C:C"). EntireColumn. AutoFit
Columns("C:C"). EntireColumn. AutoFit
Columns("D:D"). EntireColumn. AutoFit
Columns("F:F"). EntireColumn. AutoFit
Columns("G:G"). EntireColumn. AutoFit
Columns("H:H"). EntireColumn. AutoFit
fila = Range("A" & Rows.Count).End(xlUp).Row
Rows("2:2").Select
Selection.AutoFilter
Columns("D:D").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("G:G").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("H:H").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("P:P").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("P:P").NumberFormat = "General"
Range("D3").FormulaR1C1 = "=RIGHT(RC[-1],3)"
Range("D3").AutoFill Destination:=Range("D3:D" & fila)
Range("G3").FormulaR1C1 = "=VLOOKUP(RC[-3],base.xlsm!cc,4,0)"
Range("G3").AutoFill Destination:=Range("G3:G" & fila)
Range("H3").FormulaR1C1 = "=VLOOKUP(RC[-6],base.xlsm!cuentas,8,0)"
Range("H3").AutoFill Destination:=Range("H3:H" & fila)
Range("P3").FormulaR1C1 = "=DATEDIF(RC[-1],TODAY(),""d"")"
Range("P3").AutoFill Destination:=Range("P3:P" & fila)
Range("AW3").FormulaR1C1 = "=VLOOKUP(RC[-1],base.xlsm!compania,2,0)"
Range("AW3").AutoFill Destination:=Range("AW3:AW" & fila)

'selecionar

Range("D3", Range("D3").End(xlDown)).Select
'Range("D2", Range("D2").End(xlDown)).Copy

'pegar valores
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False

Range("H3", Range("H3").End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False

Range("P3", Range("P3").End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False

Range("AW3", Range("AW3").End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False

Dim Rango As Range, Cadacelda As Variant
Set Rango = Range("D3", Range("D3").End(xlDown))
For Each Cadacelda In Rango
Cadacelda.FormulaLocal = Cadacelda.FormulaLocal
Next

aqui intente eliminarlas directamente de la formula

'Dim Celda As Range
'For Each Celda In Range("G:G")
'If IsError(Celda.Value) Then Selection.EntireRow.Delete
'Next Celda

Range("G3", Range("G3").End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False

'Dim i As Integer, nfilas As Integer
'nfilas = ActiveSheet.Cells(1, 1).CurrentRegion.Rows.Count
'For i = nfilas To 2 Step -1
'Cells(i, "G").Select
'If Cells(i, "G") = "#N/A" Then
'ActiveCell.EntireRow.Select
'section.Delete
'End If
'Next i

End Sub

Añade tu respuesta

Haz clic para o