Está en la página 1de 2

jun/11

VBA Manejo de filas(encontrar ultima fila, ultima columna, suprimir celdas vacias..etc)
por admin en la categoría Código VBA Filas Excel ± macros VBA Encontrar última fila intUltimaFila = Columns(³A:A´).Range(³A65536 ).End(xlUp).Row Encontrar última fila intUltimaFila = ActiveSheet.UsedRange.Row ± 1 + ActiveSheet.UsedRange.Rows.Count Encontrar última fila MaxRow = Cells.SpecialCells(xlLastCell).Row MaxCol = Cells.SpecialCells(xlLastCell).Column Encontrar última celda (buscar al revés) Dim lngUltimaCelda As Long If WorksheetFunction.CountA(Cells) > 0 Then lngUltimaCelda = Cells.Find(What:=´*´, After:=[A1], _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious).Row MsgBox lngUltimaCelda End If Encontrar última fila (en columna especificada) Dim intUltimaFila As Range If WorksheetFunction.CountA(Columns(1)) > 0 Then Set intUltimaFila = Range(³65536 ).End(xlUp) MsgBox intUltimaFila.Address End If Suprimir filas vacías intLastRow = Columns(³A:A´).Range(³A65536 ).End(xlUp).Row For r = intLastRow To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete Next r

WorksheetFunction.Delete Next r Suprimir filas por condición Dim rngString As Range Do Set rngString = Cells.Delete Next i .EntireRow.Find(³Aglis´.SpecialCells(xlCellTypeLastCell). _ LookAt:=xlPart.Select intNumDeFilas = Selection. MatchCase:=False.Suprimir filas vacías Dim intNumDeFilas As Long Selection.UsedRange.Rows.Delete End If Next Suprimir filas vacías intUltimaFila = ActiveSheet. 2) If strTest <> ³X´ And strTest <> ³Y´ Then Rows(i).Count For r = intUltimaFila To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r). Y For i = intUltimaFila To 1 Step -1 Let strTest= Application.Delete End If Loop Until rngString Is Nothing Suprimir filas vacías por dos condiciónes X.Row For i = 1 To intNumDeFilas If Application.Row ± 1 + ActiveSheet. LookIn:=xlValues) If Not rngString Is Nothing Then rngString.UsedRange.CountA(Rows(i)) = 0 Then Rows(i).Cells(i.