RE:velocidad de ejecucion de macros
El código es el siguiente:
Sub OCULTAR()
Dim SUM
Dim SUM2
Dim i
Dim ContLinies
Dim PosicioSuma
Dim ContFulls
Dim ContFullsTotal
Dim ocultar_ant
ContLinies = 10
ContFulls = 1
Cells(2, 9) = "Pag. " & ContFulls & " /"
For i = 10 To MAX_LINEAS
Select Case Cells(i, 13)
Case "R": ContLinies = ContLinies + 1
Case "T":
If Cells(i, 6) = "" And Cells(i, 9) = 0 Then 'OCULTAR EL TITOL I TOT si preu=0
Rows(i).Select
Selection.EntireRow.Hidden = True
For ii = 0 To 17
Rows(i + ii).Select
Selection.EntireRow.Hidden = True
Next ii
i = i + 17
ocultar_ant = True
Else
ContLinies = ContLinies + 1
ocultar_ant = False
End If
SUM = SUM + Cells(i, 9)
Case "M":
If Cells(i, 4) = "" Then 'OCULTAR LA LINEA DE MATERIAL
Rows(i).Select
Selection.EntireRow.Hidden = True
Else
If Cells(i, 7) = "." Then 'oculto la linea para vista cliente, material en blanco
Rows(i).Select
Selection.EntireRow.Hidden = True
Else
ContLinies = ContLinies + 1
End If
End If
Case "I": Rows(i).Select
Selection.EntireRow.Hidden = True
Case "S": PosicioSuma = i
Cells(i, 6).ClearContents
Rows(i).Select
Selection.EntireRow.Hidden = True
SUM2 = SUM
Case "E": 'Deixem l'espai lliure
If ocultar_ant Then 'ocultem tot i la linia E
Rows(i).Select
Selection.EntireRow.Hidden = True
ContLinies = ContLinies - 2
End If
ContLinies = ContLinies + 1
Case "ER": 'omplir linies en blanc per deixar la suma final al final de la pagina, cont fins a 44
If ContLinies < 44 Then
Rows(i).Select
Selection.EntireRow.Hidden = False
ContLinies = ContLinies + 1
Else
Rows(i).Select
Selection.EntireRow.Hidden = True
End If
Case "H": ContLinies = ContLinies + 1
Case "F": i = MAX_LINEAS
Case Else:
End Select
If ContLinies > 50 Then
For s = 0 To 11
Rows(PosicioSuma - s).Select
Selection.EntireRow.Hidden = False
Next s
Set ActiveSheet.HPageBreaks(ContFulls).Location = Cells(PosicioSuma - 10, 1)
ContFulls = ContFulls + 1
SUM2 = Format(SUM2, "##,##0 €")
Cells(PosicioSuma - 11, 9) = "SUMA PROVISIONAL..... " & SUM2
Cells(PosicioSuma - 10, 9) = "Pág. " & ContFulls & " /"
Cells(PosicioSuma - 8, 2) = Cells(4, 2)
Cells(PosicioSuma - 7, 2) = Cells(5, 2)
Cells(PosicioSuma - 6, 2) = Cells(6, 2)
Cells(PosicioSuma - 5, 2) = Cells(7, 2)
Cells(PosicioSuma - 3, 2) = Cells(9, 2)
Cells(PosicioSuma - 8, 7) = Cells(4, 7)
Cells(PosicioSuma - 3, 7) = Cells(9, 7)
Cells(PosicioSuma - 2, 7) = Cells(10, 7)
Cells(PosicioSuma - 2, 8) = Cells(10, 8)
Cells(PosicioSuma, 9) = "SUMA ANTERIOR............ " & SUM2
ContLinies = i - (PosicioSuma - 10)
End If
ContFullsTotal = ContFulls
Cells(2, 10) = ContFullsTotal
Next i
Columns("C:E").Select
Selection.EntireColumn.Hidden = True
Columns("K:M").Select
Selection.EntireColumn.Hidden = True
Cells(11, 2).Select
End Sub
Para poneros un poco en el sitio, este código pertenece a una hoja para hacer presupuesto en la que se ocultan las filas y columnas que no se utilizan.