Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

filtro vacias

publicado

Hola amigos 

De nuevo solicitando su apoya para resolver un tema, al filtrar ciertos datos y requiero copiar la información para procesarla solo que cuando no hay datos se produce un error 1004  como podria condicionarla con un if thense 

Sub copiar_filtro()

ActiveSheet.Range("$A$5:$D$11").SpecialCells(xlCellTypeVisible).Copy


End Sub


Sub filtro()


Range("A5").CurrentRegion.AutoFilter Field:=4, Criteria1:=Sheets("base").Range("c4").Value
    
End Sub

filtro vacias.xlsm

 

de antemano gracias

 

 

 

 

Featured Replies

publicado

Hola @juancyuky

No se puede descargar un archivo, pero una solución rápida y práctica podría ser:

 

Sub filtro()

A = Application.WorksheetFunction.CountIf(Range("$A$5:$D$11"), Sheets("base").Range("c4").Value)
If A >= 1 Then Range("A5").CurrentRegion.AutoFilter Field:=4, Criteria1:=Sheets("base").Range("c4").Value
'If A <> 0 Then Range("A5").CurrentRegion.AutoFilter Field:=4, Criteria1:=Sheets("base").Range("c4").Value
    
End Sub

Espero se de utilidad, Sigo atento.

Editado el por Mauricio_ODN

publicado
  • Autor

Hola Mauricio,

 

Voy a intentar con tu valioso aporte y en este momento anexe el xlsm que al parecer no se cargo anteriormente

y te comento si me resulto

Muchas gracias!!!

filtro vacias.xlsm

publicado

A veces con algún truquillo salimos del paso:

Sub copiar_filtro() 'Copiamos también la fila 4
Set Rango = ActiveSheet.Range("$A$4:$D$11").SpecialCells(xlCellTypeVisible)
If Rango.Rows.Count > 1 Then Rango.Copy
End Sub

o también:

Sub copiar_filtro(): On Error GoTo SinDatos
ActiveSheet.Range("$A$5:$D$11").SpecialCells(xlCellTypeVisible).Copy
Exit Sub
SinDatos:
   MsgBox "*** Sin datos***", vbInformation
End Sub

 

publicado

El filtro funcionaría mejor así:

Sub filtro()
Range("A5").AutoFilter Field:=4, Criteria1:=Sheets("base").Range("c4").Value
End Sub

 

publicado
  • Autor

Gracias Antoni,

finalmente me funciono con el siguiente código:

Sub filtro_final()

'final

A = Application.WorksheetFunction.CountIf(Range("$A$5:$D$11"), Sheets("base").Range("c4").Value)
If A >= 1 Then Range("A5").CurrentRegion.AutoFilter Field:=4, Criteria1:=Sheets("base").Range("c4").Value
If A = 0 Then MsgBox "NO HAY DATOS QUE COPIAR" 
End Sub

gracias por sus aportes tuve otras ideas para tomar en cuenta, doy por cerrado el tema y adjunto el docto.final

 

 

 

 

 

 

 

 

 

filtro vacias.xlsm

Archivado

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.