Error de hojas ocultas en macros (excel)
Tengo 12 hojas de Excel oculta y una hoja visible que se llama calcular y al momento de correr los macros me dice que hay un error por que no encuentran las hojas ocultas........ La única hoja que necesito es la de calcular.
los códigos que llevo usando son estos:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim dia, mes As Variant
Dim mat(6, 12) As Variant
Dim i, j, fila As Integer
Sheets("CALCULAR").Select
dia = ActiveSheet.Cells(2, 2)
mes = ActiveSheet.Cells(2, 3)
Sheets("ENERO").Select
fila = 1
For i = 2 To 187
If (dia = ActiveSheet.Cells(i, 2)) And (mes = ActiveSheet.Cells(i, 3)) Then
ActiveSheet.Cells(i, 2).Select
For j = i To (i + 5)
ActiveSheet.Cells(j, 2).Select
mat(fila, 1) = ActiveSheet.Cells(j, 5)
mat(fila, 2) = ActiveSheet.Cells(j, 6)
mat(fila, 3) = ActiveSheet.Cells(j, 7)
mat(fila, 4) = ActiveSheet.Cells(j, 8)
mat(fila, 5) = ActiveSheet.Cells(j, 9)
mat(fila, 6) = ActiveSheet.Cells(j, 10)
mat(fila, 7) = ActiveSheet.Cells(j, 11)
mat(fila, 8) = ActiveSheet.Cells(j, 12)
mat(fila, 9) = ActiveSheet.Cells(j, 13)
mat(fila, 10) = ActiveSheet.Cells(j, 14)
mat(fila, 11) = ActiveSheet.Cells(j, 15)
mat(fila, 12) = ActiveSheet.Cells(j, 16)
fila = fila + 1
Next
i = 187
End If
Next
Sheets("CALCULAR").Select
fila = 1
For j = 7 To 12
ActiveSheet.Cells(j, 4).Select
ActiveSheet.Cells(j, 4) = mat(fila, 1)
ActiveSheet.Cells(j, 5) = mat(fila, 2)
ActiveSheet.Cells(j, 6) = mat(fila, 3)
ActiveSheet.Cells(j, 7) = mat(fila, 4)
ActiveSheet.Cells(j, 8) = mat(fila, 5)
ActiveSheet.Cells(j, 9) = mat(fila, 6)
ActiveSheet.Cells(j, 10) = mat(fila, 7)
ActiveSheet.Cells(j, 11) = mat(fila, 8)
ActiveSheet.Cells(j, 12) = mat(fila, 9)
ActiveSheet.Cells(j, 13) = mat(fila, 10)
ActiveSheet.Cells(j, 14) = mat(fila, 11)
ActiveSheet.Cells(j, 15) = mat(fila, 12)
fila = fila + 1
Next
End sub
para las demás hojas solo se necesita repetir este procedimiento.