Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

244
Visualizações
eliminando filas enteras si el valor se encuentra en una lista vba

Tengo una lista de alrededor de 200 nombres (en una hoja) que necesito probar y filtrar (y eliminar) de una hoja de datos. Estoy luchando por saber cómo configurar la lista de nombres como una matriz para poder filtrar esa matriz en Range("E:E").AutoFilter Field:=1, Criteria1:=**Array Here**, _ y luego fullrow.delete.

Este es mi intento más reciente basado en otras fuentes en línea, pero parece que la mayoría de ellas son listas que solo contienen 4-5 valores, y estoy luchando por encontrar algo que sea útil para poner todos los valores en un matriz y filtrándolos en función de eso, cualquier ayuda / solución alternativa es apreciada, ¡gracias!

 Call myArrayRange Dim rng As Range Dim pos As Integer Dim arr As String Set arr = Worksheets("control").Range("K2:K10000") Set sht = ws With sht Range("E:E").AutoFilter Field:=1, Criteria1:=Array(""), _ Operator:=xlFilterValues LstRw = .Cells(.Rows.Count, "A").End(xlUp).Row Set rng = .Range("A2:A" & LstRw).SpecialCells(xlCellTypeVisible) rng.EntireRow.Delete .AutoFilterMode = False End With End Sub Sub myArrayRange() lr = Worksheets("Control").Cells(Rows.Count, 11).End(xlUp).Row Dim iAmount() As Variant Dim iNum As Integer iAmount = Range("K2:K" & lr) For iNum = 1 To UBound(iAmount) Debug.Print iAmount(iNum, 1) Next iNum End Sub```
about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

EDITAR : actualizado para que coincida con su caso de uso real.

Aquí tienes un ejemplo básico de cómo puedes hacerlo:

 Sub Tester() Dim arr, rngNames as range, ws As Worksheet Set ws = ActiveSheet 'for example: the sheet with the data to filter With ws.Parent.Worksheets("Control") Set rngNames = .Range("K2:K" & .Cells(.Rows.Count, "K").End(xlUp)) End With arr = RangeToArray(rngNames) 'get an array from the list of names ws.Range("E:E").AutoFilter Field:=1, Criteria1:=arr, _ Operator:=xlFilterValues ws.Autofilter.Range.SpecialCells(xlCellTypeVisible).EntireRow.Delete ws.AutoFilterMode = False End Sub 'convert a range to a zero-based 1D array Function RangeToArray(rng As Range) Dim r As Long, c As Long, arr, data, i data = rng.Value 'get the source data ReDim arr(0 To rng.Cells.Count - 1) 'size the output array For r = 1 To UBound(data, 1) 'loop over the data from the range For c = 1 To UBound(data, 2) arr(i) = data(r, c) i = i + 1 Next c Next r RangeToArray = arr End Function
about 4 years ago · Santiago Trujillo Relatório

0

Esta es una forma realmente peligrosa de eliminar cosas. Realmente no puede recuperar los datos, así que asegúrese de que el filtro funcione.

 Sub Button1_Click() myArrayRange End Sub Sub myArrayRange() Dim rng As Range Dim pos As Integer Dim sht As Worksheet Set sht = ActiveSheet With sht 'Your string array that holds names would go here VVVV (According to MS Docs) Range("E:E").AutoFilter Field:=1, Criteria1:=Array(""), _ Operator:=xlFilterValues LstRw = .Cells(.Rows.Count, "A").End(xlDown).Row Set rng = .Range("A2:A" & LstRw).SpecialCells(xlCellTypeVisible) rng.EntireRow.Delete .AutoFilterMode = False End With End Sub

Tendrás que encontrar la hoja que necesitas de alguna manera. Usé la hoja activa. Aquí hay una captura de pantalla de los datos antes y después. ingrese la descripción de la imagen aquí ingrese la descripción de la imagen aquí

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda