Saltar al contenido

macro buscar y eliminar valores

publicado

hola.

estoy desarrollando un macro que me baje un archivo plano a excel y al bajarlo necesito que me elimine la basura de este archivo plano; pero lo e intentado de varias formas y no e podido eliminar la basura de ese archivo esta fue la ultima forma que intente pero no lo elimina todo me saca erro 91 y no me deja continuar.

Sub Macro1()

'

' Macro1 Macro

'

'

ChDir "D:\"

Workbooks.OpenText Filename:="D:\UFCG1041.PJB", Origin:=xlMSDOS, StartRow _

:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(10, 1), Array _

(43, 1), Array(66, 1), Array(68, 1), Array(89, 1), Array(114, 1), Array(135, 1), Array(137, _

1)), DecimalSeparator:=".", ThousandsSeparator:=",", TrailingMinusNumbers _

:=True

Do

Cells.Find(What:="+-", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _

xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _

, SearchFormat:=False).Activate

Selection.EntireRow.Delete

Selection.End(xlUp).Select

Cells.Find(What:="|", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _

xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _

, SearchFormat:=False).Activate

Selection.EntireRow.Delete

Selection.End(xlUp).Select

Cells.Find(What:="|", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _

xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _

, SearchFormat:=False).Activate

Selection.EntireRow.Delete

Selection.End(xlUp).Select

Loop

End Sub

Featured Replies

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.