Filtrar desde un rango de celdas VBA

Luifer2908

New Member
Joined
Jan 11, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Porfa necesito de su ayuda a este codigo como le puedo agregar para realizar un doble filtro (Dia semana / semana) pero las semanas son un rango de celdas. Este es ele codigo:::::

Private Sub Worksheet_Change (ByVal Target As Range)

'Esta línea detiene la actualización de la hoja de trabajo en cada cambio, solo se actualiza cuando la celda
'H6 o H7 se toca
Si Intersect (Target, Range ("P1: AL1")) no es nada, entonces salga de Sub

'Establecer las variables que se utilizarán
Dim pt como tabla dinámica
Atenuar Field1 como PivotField
Dim Field2 como PivotField
Atenuar Field3 como PivotField
Dim Field4 como PivotField
Dim Field5 como PivotField
Dim Field6 como PivotField
Atenuar Field7 como PivotField
Dim Field8 como PivotField
Dim Field9 como PivotField
Dim Field10 como PivotField
Dim Field11 como PivotField
Dim Field12 como PivotField
Dim Field13 como PivotField
Dim Field14 como PivotField

Dim NewCat1 como cadena
Dim NewCat2 como cadena
Dim NewCat3 como cadena
Dim NewCat4 como cadena
Dim NewCat5 como cadena
Dim NewCat6 como cadena
Dim NewCat7 como cadena
Dim NewCat8 como cadena
Dim NewCat9 como cadena
Dim NewCat10 como cadena
Dim NewCat11 como cadena
Dim NewCat12 como cadena
Dim NewCat13 como cadena
Dim NewCat14 como cadena


'Aquí se modifica para adaptarse a sus datos
Establecer pt = Hojas de trabajo ("Hoja3"). Tablas dinámicas ("F")
Establecer Field1 = pt.PivotFields ("Dia semana")
Establecer Field2 = pt.PivotFields ("P1")
NewCat1 = Hojas de trabajo ("Hoja3"). Rango ("P1"). Valor
NewCat2 = Hojas de trabajo ("Hoja3"). Rango ("Q1"). Valor
Establecer pt = Hojas de trabajo ("Hoja3"). Tablas dinámicas ("G")
Establecer Field1 = pt.PivotFields ("Dia semana")
Establecer Field3 = pt.PivotFields ("P2")
NewCat3 = Hojas de trabajo ("Hoja3"). Rango ("R1"). Valor
Establecer pt = Hojas de trabajo ("Hoja3"). Tablas dinámicas ("H")
Establecer Field1 = pt.PivotFields ("Dia semana")
Establecer Field4 = pt.PivotFields ("P3")
NewCat4 = Hojas de trabajo ("Hoja3"). Rango ("S1"). Valor
Establecer pt = Hojas de trabajo ("Hoja3"). Tablas dinámicas ("I")
Establecer Field1 = pt.PivotFields ("Dia semana")
Establecer Field5 = pt.PivotFields ("P4")
NewCat5 = Hojas de trabajo ("Hoja3"). Rango ("T1"). Valor
Establecer pt = Hojas de trabajo ("Hoja3"). Tablas dinámicas ("J")
Establecer Field1 = pt.PivotFields ("Dia semana")
Establecer Field6 = pt.PivotFields ("SIGNO")
NewCat6 = Hojas de trabajo ("Hoja3"). Rango ("U1"). Valor
Establecer pt = Hojas de trabajo ("Hoja3"). Tablas dinámicas ("A")
Establecer Field7 = pt.PivotFields ("Dia semana")
NewCat7 = Hojas de trabajo ("Hoja3"). Rango ("V1"). Valor
Establecer pt = Hojas de trabajo ("Hoja3"). Tablas dinámicas ("K")
Establecer Field8 = pt.PivotFields ("P1")
NewCat8 = Hojas de trabajo ("Hoja3"). Rango ("Q1"). Valor
Establecer pt = Hojas de trabajo ("Hoja3"). Tablas dinámicas ("L")
Establecer Field9 = pt.PivotFields ("P2")
NewCat9 = Hojas de trabajo ("Hoja3"). Rango ("R1"). Valor
Establecer pt = Hojas de trabajo ("Hoja3"). Tablas dinámicas ("M")
Establecer Field10 = pt.PivotFields ("P3")
NewCat10 = Hojas de trabajo ("Hoja3"). Rango ("S1"). Valor
Establecer pt = Hojas de trabajo ("Hoja3"). Tablas dinámicas ("N")
Establecer Field11 = pt.PivotFields ("P4")
NewCat11 = Hojas de trabajo ("Hoja3"). Rango ("T1"). Valor
Establecer pt = Hojas de trabajo ("Hoja3"). Tablas dinámicas ("O")
Establecer Field12 = pt.PivotFields ("SIGNO")
NewCat12 = Hojas de trabajo ("Hoja3"). Rango ("U1"). Valor

Establecer pt = Hojas de trabajo ("Hoja3"). Tablas dinámicas ("P")
Establecer Field13 = pt.PivotFields ("Dia semana")
Establecer Field14 = pt.PivotFields ("Semanas")
NewCat13 = Hojas de trabajo ("Hoja3"). Rango ("V1"). Valor
NewCat14 = Worksheets ("Hoja3"). Range ("W1: AL1"). Value (es a esta parte que no se como llamar el rango que comprende desde la W1: AL1 y me arroja este error.

1610429904603.png


1610429904603.png
este es el resto del codigo.

'Esto actualiza y actualiza la tabla PIVOT
Con pt
Field1.ClearAllFilters
Field1.CurrentPage = NewCat1
Field2.ClearAllFilters
Field2.CurrentPage = NewCat2
Field3.ClearAllFilters
Field3.CurrentPage = NewCat3
Field4.ClearAllFilters
Field4.CurrentPage = NewCat4
Field5.ClearAllFilters
Field5.CurrentPage = NewCat5
Field6.ClearAllFilters
Field6.CurrentPage = NewCat6
Field7.ClearAllFilters
Field7.CurrentPage = NewCat7
Field8.ClearAllFilters
Field8.CurrentPage = NewCat8
Field9.ClearAllFilters
Field9.CurrentPage = NewCat9
Field10.ClearAllFilters
Field10.CurrentPage = NewCat10
Field11.ClearAllFilters
Field11.CurrentPage = NewCat11
Field12.ClearAllFilters
Field12.CurrentPage = NewCat12
Field13.ClearAllFilters
Field13.CurrentPage = NewCat13
Field14.ClearAllFilters
Field14.CurrentPage = NewCat14
pt.RefreshTable
Terminar con
End Sub


De antemano agradezco cualquier aporte Dios les bendiga y mil mil gracias
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,214,619
Messages
6,120,550
Members
448,970
Latest member
kennimack

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