Saltar al contenido principal

¿Cómo seleccionar cada fila o enésima fila en Excel?

Cuando usamos una hoja de trabajo, a veces, tenemos que seleccionar cada dos filas o la enésima fila de la hoja para dar formato, eliminar o copiar. Puede seleccionarlos manualmente, pero si hay cientos de filas, este método no es una buena opción. Aquí hay algunos trucos para ayudarte.

Seleccione cada fila o enésima fila con VBA

Seleccione cada dos o enésima fila con Kutools para Excelbuena idea3


Seleccione cada fila o enésima fila con VBA

En este ejemplo, seleccionaré una fila con dos intervalos. Con el código VBA, puedo terminarlo de la siguiente manera:

1. Resalte el rango que desea seleccionar cada dos o enésimas filas.

2.Click Developer > Visual Basic, Un nuevo Microsoft Visual Basic para aplicaciones aparecerá la ventana, haga clic en recuadro > Móduloe ingrese el siguiente código en el módulo:

Sub EveryOtherRow()
Dim rng As Range
Dim InputRng As Range
Dim OutRng As Range
Dim xInterval As Integer
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
xInterval = Application.InputBox("Enter row interval", xTitleId, Type:=1)
For i = 1 To InputRng.Rows.Count Step xInterval + 1
    Set rng = InputRng.Cells(i, 1)
    If OutRng Is Nothing Then
        Set OutRng = rng
    Else
        Set OutRng = Application.Union(OutRng, rng)
    End If
Next
OutRng.EntireRow.Select
End Sub

3.A continuación, haga clic en doc-multiplicar-calculo-3 botón para ejecutar el código. Y aparece un cuadro de diálogo para que seleccione un rango. Ver captura de pantalla:



4. Hacer clic en OK, y en este caso, ingreso 3 en el otro diálogo emergente como fila de intervalo. Ver captura de pantalla

5. Hacer clic en OK, y se ha seleccionado cada tres filas. Ver captura de pantalla:

Puede cambiar el intervalo que necesite en el segundo KutoolsparaExcel diálogo.


Seleccione cada dos o enésima fila con Kutools para Excel

Con el código VBA, solo puede seleccionar una fila con intervalos especificados, si necesita seleccionar dos, tres u otras filas con intervalos especificados, el Kutools for Excel puede ayudarlo a resolver este problema de manera fácil y conveniente.

Kutools for Excel, con más de 300 funciones prácticas, facilita su trabajo. 

Después instalación gratuita Kutools para Excel, haga lo siguiente:

1. Hacer clic en Kutools > Select > Select Interval Rows & Columns…, Mira la captura de pantalla:

doc seleccione cada dos filas8

2. En el  Select Interval Rows & Columns cuadro de diálogo, haga clic endoc-reemplazar-rango-nombres-7 para seleccionar el rango que necesita, elija Rows or Columns en Select .y especifique el número que desea en el Interval of cuadro de entrada y Rows cuadro de entrada. Ver captura de pantalla:

doc seleccione cada dos filas9

doc seleccione cada dos filas10

Notas:
1. Si necesita seleccionar cada dos filas en la selección, ingrese 2 en el cuadro Intervalos de entrada y 1 en el Rows cuadro de entrada.

2. Si desea seleccionar toda la fila que necesita, puede marcar Select entire rows .
doc seleccione cada dos filas11


Sombree cada dos filas o enésima fila con Kutools para Excel

Si desea sombrear rangos en cada dos filas para que los datos se vean más destacados como se muestra a continuación, puede aplicar Kutools for Excel, Alternate Row/Column Shading función para manejar rápidamente el trabajo.

doc seleccione cada dos filas12
doc flecha hacia abajo
doc seleccione cada dos filas13

Después instalación gratuita Kutools para Excel, haga lo siguiente:

1. Seleccione el rango de celdas que desea dividir el tono, haga clic en Kutools > Format > Alternate Row/Column Shading.
doc seleccione cada dos filas14

2. En el Alternate Row/Column Shading diálogo, haga lo siguiente:

1) Seleccione las filas o columnas que desea sombrear;

2) Elija Conditional formatting or formato estándar como necesites;

3) Especifique el intervalo de sombreado;

4) Elija un color de sombreado.
doc seleccione cada dos filas15

3. Hacer clic en Ok. Ahora el rango se ha sombreado en cada enésima fila.

Si desea eliminar el sombreado, marque Eliminar el sombreado de fila alternativo existente en opción Sombreado alternativo de filas / columnas diálogo.


Artículos relacionados:

Las mejores herramientas de productividad de oficina

🤖 Asistente de IA de Kutools: Revolucionar el análisis de datos basado en: Ejecución inteligente   |  Generar codigo  |  Crear fórmulas personalizadas  |  Analizar datos y generar gráficos  |  Invocar funciones de Kutools...
Características populares: Buscar, resaltar o identificar duplicados   |  Eliminar filas en blanco   |  Combine columnas o celdas sin perder datos   |   Ronda sin fórmula ...
Super búsqueda: Búsqueda virtual de criterios múltiples    Búsqueda V de valores múltiples  |   VLookup en varias hojas   |   Búsqueda difusa ....
Lista desplegable avanzada: Crear rápidamente una lista desplegable   |  Lista desplegable dependiente   |  Lista desplegable de selección múltiple ....
Administrador de columnas: Agregar un número específico de columnas  |  Mover columnas  |  Toggle Estado de visibilidad de columnas ocultas  |  Comparar rangos y columnas ...
Características destacadas: Enfoque de cuadrícula   |  Vista de diseño   |   Gran barra de fórmulas    Administrador de hojas y libros de trabajo   |  Biblioteca de Recursos (Texto automático)   |  Selector de fechas   |  Combinar hojas de trabajo   |  Cifrar/descifrar celdas    Enviar correos electrónicos por lista   |  Súper filtro   |   Filtro especial (filtro negrita/cursiva/tachado...) ...
Los 15 mejores conjuntos de herramientas12 Texto Herramientas (Añadir texto, Quitar caracteres, ...)   |   50+ Tabla Tipos (Diagrama de Gantt, ...)   |   40+ Práctico Fórmulas (Calcular la edad según el cumpleaños, ...)   |   19 Inserción Herramientas (Insertar código QR, Insertar imagen desde la ruta, ...)   |   12 Conversión Herramientas (Números a palabras, Conversión de Moneda, ...)   |   7 Fusionar y dividir Herramientas (Filas combinadas avanzadas, Células partidas, ...)   |   ... y más

Mejore sus habilidades de Excel con Kutools for Excel y experimente la eficiencia como nunca antes. Kutools for Excel ofrece más de 300 funciones avanzadas para aumentar la productividad y ahorrar tiempo.  Haga clic aquí para obtener la función que más necesita...

Descripción


Office Tab lleva la interfaz con pestañas a Office y hace que su trabajo sea mucho más fácil

  • Habilite la edición y lectura con pestañas en Word, Excel, PowerPoint, Publisher, Access, Visio y Project.
  • Abra y cree varios documentos en nuevas pestañas de la misma ventana, en lugar de en nuevas ventanas.
  • ¡Aumenta su productividad en un 50% y reduce cientos de clics del mouse todos los días!
Comments (12)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Help, please. This looks great, BUT when I hit the > Run button it fails with a "Compile error: Sub or Function not defined" and the code stopped at "Set rng = InputRng.Rows.Count Step xInterval +1".
This comment was minimized by the moderator on the site
Also I don't get how "Set" and "Step" could ever work together
This comment was minimized by the moderator on the site
Not sure that I will be able to help, but.. First of, there is a spacing between "C" and "ount" in "Count" when i copied your code string over to a module. Secondly, I can´t find your code anywhere else on this page, please submit the whole thing, if the problem remains.
This comment was minimized by the moderator on the site
Replace OutRng.EntireRow.Select with Intersect(OutRng.EntireRow, InputRng).Select if you want every other row within your selection
This comment was minimized by the moderator on the site
really good, thanks!
This comment was minimized by the moderator on the site
The code has one request. Does it have to select the ENTIRE ROW for each nth row? Can't it just select certain cells (range of cells) within each nth row? I don't need all the information in each row. Just certain cells of each nth row.
This comment was minimized by the moderator on the site
I made the modifications below to select 30 rows Sub EveryOtherRow() Dim rng As Range Dim InputRng As Range Dim OutRng As Range Dim xInterval As Integer xTitleId = "KutoolsforExcel" Set InputRng = Application.Selection Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8) xInterval = Application.InputBox("Enter row interval", xTitleId, Type:=1) For i = 1 To InputRng.Rows.Count Step xInterval + 1 Set rng = InputRng.Cells(i, 1).Resize(, 30) 'Resize to the number of columns to select, 30 in this case If OutRng Is Nothing Then Set OutRng = rng Else Set OutRng = Application.Union(OutRng, rng) End If Next OutRng.Select 'Use OutRng.EntireRow.Select to select the entire row End Sub
This comment was minimized by the moderator on the site
Nice, thanks, this was very helpful ^_^
This comment was minimized by the moderator on the site
fanatastic. thanks a lot.it works perfect.I have more than 7000 data that need to select them with different interval.this trick was like a miracle for me.thaaaaaaaanks.
This comment was minimized by the moderator on the site
I'm trying to use the VBA macro in Excel 2010. It will only select the first nth row, not all of them in the selection. If I run it again, it will go to the next. Any idea what I'm doing wrong? Thanks!
This comment was minimized by the moderator on the site
Just saved my ass with this code thanks! My matlab decided to randomly stop working and so I had to resort to excel which I am not as familiar with as with Matlab. This def. helped. Thanks.
This comment was minimized by the moderator on the site
I need to select multiple rows and a fixed interval and move to the other sheet please answer me as soon as possible 
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations