<font face=Consolas, "Lucida Sans Typewriter", "Lucida Console", "Courier New", Monospace><SPAN style="color:#00007F">Option</SPAN> <SPAN style="color:#00007F">Explicit</SPAN><br><SPAN style="color:#007F00">'// -----------------------------------------------------------------</SPAN><br><SPAN style="color:#007F00">'// escrito por Greg Truby</SPAN><br><SPAN style="color:#007F00">'// escrito para lalo001</SPAN><br><br><SPAN style="color:#007F00">'// resumen - lalo001 quiere esconder todas las columnas y ringlones</SPAN><br><SPAN style="color:#007F00">'// que estén completamente vacias dentro de un rango dado.</SPAN><br><SPAN style="color:#007F00">'// -----------------------------------------------------------------</SPAN><br><br><SPAN style="color:#007F00">'// ponga el valor de TRUE para este constante si quiere ver detalles</SPAN><br><SPAN style="color:#007F00">'// de la operacion en la ventana de observación.</SPAN><br><SPAN style="color:#00007F">Const</SPAN> mc_booDebugMode <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Boolean</SPAN> = <SPAN style="color:#00007F">False</SPAN><br><br><br><SPAN style="color:#007F00">'// cambie la dirección de las celdas aquí. O mejor</SPAN><br><SPAN style="color:#007F00">'// use un rango nombrado y ponga el nombre del rango</SPAN><br><SPAN style="color:#007F00">'// aquí.</SPAN><br><SPAN style="color:#00007F">Const</SPAN> mc_strAddressToReview <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN> = "A3:AB164"<br><br><br><SPAN style="color:#00007F">Sub</SPAN> EsconderVacios()<br> <br> <SPAN style="color:#00007F">Dim</SPAN> lngCounter <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, _<br> rngReviewCol <SPAN style="color:#00007F">As</SPAN> Excel.Range, _<br> rngReviewRow <SPAN style="color:#00007F">As</SPAN> Excel.Range, _<br> rngToReview <SPAN style="color:#00007F">As</SPAN> Excel.Range, _<br> wf <SPAN style="color:#00007F">As</SPAN> Excel.WorksheetFunction<br><br> <SPAN style="color:#007F00">'// note que no se use la palabra NEW, es solo un SET</SPAN><br> <SPAN style="color:#00007F">Set</SPAN> wf = Application.WorksheetFunction<br> <br> <SPAN style="color:#007F00">'// vamos a suponer que se trata de la hoja activa</SPAN><br> <SPAN style="color:#00007F">Set</SPAN> rngToReview = Range(mc_strAddressToReview)<br> <SPAN style="color:#00007F">If</SPAN> mc_booDebugMode <SPAN style="color:#00007F">Then</SPAN> Debug.Print "Using Sheet: " & rng<SPAN style="color:#00007F">To</SPAN>Review.Parent.Name<br> <br> <SPAN style="color:#007F00">'// ----------------------------------------------------------------</SPAN><br> <SPAN style="color:#007F00">'// realmente sería posible no usar unas variables como</SPAN><br> <SPAN style="color:#007F00">'// rngReviewCol o rngReviewRow. Pero usarlas hace el proceso de</SPAN><br> <SPAN style="color:#007F00">'// "matar bichos" (debugging) más fácil.</SPAN><br> <SPAN style="color:#007F00">'// ----------------------------------------------------------------</SPAN><br> <br> <br> <SPAN style="color:#007F00">'// buscamos ringlones vacios</SPAN><br> <SPAN style="color:#00007F">For</SPAN> lngCounter = 1 To rngToReview.Rows.Count<br> <br> <SPAN style="color:#00007F">Set</SPAN> rngReviewRow = rng<SPAN style="color:#00007F">To</SPAN>Review.Rows(lngCounter)<br> <br> <SPAN style="color:#00007F">If</SPAN> mc_booDebugMode <SPAN style="color:#00007F">Then</SPAN> Debug.Print rngReviewRow.Address(0, 0), "|", wf.CountA(rngReviewRow)<br> <br> rngReviewRow.EntireRow.Hidden = (wf.CountA(rngReviewRow) = 0)<br> <br> <SPAN style="color:#00007F">Next</SPAN> lngCounter<br> <br> <SPAN style="color:#007F00">'// ahora revisamos las columnas</SPAN><br> <SPAN style="color:#00007F">For</SPAN> lngCounter = 1 To rngToReview.Columns.Count<br> <br> <SPAN style="color:#00007F">Set</SPAN> rngReviewCol = rngToReview.Columns(lngCounter)<br> <br> <SPAN style="color:#00007F">If</SPAN> mc_booDebugMode <SPAN style="color:#00007F">Then</SPAN> Debug.Print rngReviewCol.Address(0, 0), "|", wf.CountA(rngReviewCol)<br> <br> rngReviewCol.EntireColumn.Hidden = (wf.CountA(rngReviewCol) = 0)<br> <br> <SPAN style="color:#00007F">Next</SPAN> lngCounter<br> <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br><br><SPAN style="color:#00007F">Sub</SPAN> ShowAllWithinRange()<br> <SPAN style="color:#00007F">With</SPAN> Range(mc_strAddressToReview)<br> .EntireColumn.Hidden = <SPAN style="color:#00007F">False</SPAN><br> .EntireRow.Hidden = <SPAN style="color:#00007F">False</SPAN><br> <SPAN style="color:#00007F">End</SPAN> With<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>