seleccion

emiaj61

New Member
Joined
Dec 11, 2006
Messages
17
existe manera de seleccionar al mismo tiempo varias hojas ( Sheets ) de un mismo libro de trabajo (workbook ) usando vb ?
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Prueba con esto:

selecciona toda hoja cuyo Index sea mayor que 2 ....

Code:
Sub SheetsSelected()
    
Dim shtArr() As String, sh As Worksheet
Dim i As Integer
i = 0
ReDim shtArr(ThisWorkbook.Worksheets.Count - 1)
For Each sh In Worksheets
    If sh.Index > 2 Then
        ReDim Preserve shtArr(i)
        shtArr(i) = sh.Name
        i = i + 1
    End If

Next sh


Sheets((shtArr)).Select

End Sub
A la primera pregunta que te haces podrias haberte respondido con la "Grabadora de macros", es decir ¿Es posible seleccionar Hojas desde VB?. SI

Si algo se puede hacer grabando una Macro, entonces seguro que se puede programar desde VB y aun mejor...

Ojo no es cierta la contrareciproca: Si algo no se puede con la Grabadora de macros, entonces.....entonces.....consulta......

GALILEOGALI
 
Upvote 0
Code:
Sub SheetsSelectedPares()
    
Dim shtArr() As String, sh As Worksheet
Dim i As Integer
i = 0

For Each sh In Worksheets
    If sh.Index Mod 2 = 0 Then
        ReDim Preserve shtArr(i)
        shtArr(i) = sh.Name
        i = i + 1
    End If

Next sh


Sheets((shtArr)).Select

End Sub
Eliminé el primer REDIM pues era innecesario. Esta ultima selecciona las hojas pares (de acuerdo al INDEX).

GALI
<hr />Ambos mensajes de Gali editado por Greg para poner las etiquetas de «code».
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,273
Members
448,559
Latest member
MrPJ_Harper

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top