delete rows with insrt text in the formula

AMAIA

New Member
Joined
Jan 10, 2022
Messages
3
Office Version
  1. 2016
Platform
  1. Web
hola necesito borrar filas que contienen #Ref en la fórmula, pero no las fórmulas cuyo valor es #ref tengo la siguiente instrucción pero solo borra la primera celda con y no continúa


Sub eliminar ()
Rango de atenuación como rango
Dim pos como entero
Dim i como entero


Establecer rng = Range("b:f").SpecialCells(xlCellTypeFormulas)
Para i = rng.Cells.Count To 1 Paso -1
pos = InStr(LCase(rng.Item(i).Formula), LCase("#REF!"))
Si pos > 0 Entonces

rng.Item(i).EntireRow.Delete

Terminara si
Siguiente yo

End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Prueba el siguiente código:

VBA Code:
Sub EliminarFilas()
  Dim lr As Long
  Dim c As Range, Rng As Range
  
  Application.ScreenUpdating = False
  lr = ActiveSheet.Range("B:F").Find("*", , xlValues, , xlByRows, xlPrevious).Row
  For Each c In Range("B1", Range("B" & lr))
    If InStr(1, LCase(c.Formula & "|" & c.Offset(, 1).Formula & "|" & c.Offset(, 2).Formula _
        & "|" & c.Offset(, 3).Formula & "|" & c.Offset(, 4).Formula), LCase("#REF!")) > 0 Then
      If Rng Is Nothing Then Set Rng = c Else Set Rng = Union(Rng, c)
    End If
  Next
  If Not Rng Is Nothing Then Rng.EntireRow.Delete
End Sub
 
Upvote 0
Prueba el siguiente codigo:

[CÓDIGO=vba]
Sub EliminarFilas()
Dim lr siempre
Dim c como rango, Rng como rango

Application.ScreenUpdating = Falso
lr = ActiveSheet.Range("B:F").Find("*", , xlValues, , xlByRows, xlPrevious).Row
Para cada c en rango ("B1", rango ("B" & lr))
If InStr(1, LCase(c.Fórmula & "|" & c.Offset(, 1).Fórmula & "|" & c.Offset(, 2).Fórmula _
& "|" & c.Desplazamiento(, 3).Fórmula & "|" & c.Offset(, 4).Fórmula), LCase("#REF!")) > 0 Entonces
Si Rng no es nada, entonces establezca Rng = c De lo contrario, establezca Rng = Union (Rng, c)
Terminara si
próximo
Si no Rng no es nada, entonces Rng.EntireRow.Delete
Finalizar sub

[/CÓDIGO]
Gracias pero no funciona, me marca un error 1004 range
[CÓDIGO=vba]
Sub Eliminar filas ()

Rango de atenuación como rango

Dim pos como entero

Dim i como variante

Establecer rng = Rango ("b: f")


Para i = rng.Cells.Count To 1 Paso -1

pos = InStr(LCase(rng.Item(i).Formula), LCase("#REF!"))

Si pos > 0 Entonces

rng.Item(i).EntireRow.Delete

Terminara si

Siguiente yo

Finalizar sub
[/CODIGO]


esta macro funciona pero es muy lenta
 
Upvote 0
Gracias pero no funciona, me marca un error 1004 range
Puedes comentar qué dice exactamente el mensaje de error.
En qué línea se detiene la macro.

Nota: 2 cosas, cuando pongas código en el foro, evita que haga la traducción y pon el código utilizando el icono de VBA Code tag.
1641943686108.png


Un par de cosas más. En cuál columna tienes el texto "REF" en la "B"?
En algunas celdas tienes como resultado de la fórmula un error?
Podrías poner una imagen, con una muestra de cómo están tus datos en la hoja.
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,454
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top