Buenas llevo días trabajando sobre una macro la cual realiza varios calculos, obtiene datos, etc. El problema es que cuando la ejecuto excel aparece como no responde. Tarda bastante y no veo que coja todo los recurso del pc. Dicho esto lanzo mis dudas.
*Viendo esta programación creéis que es normal no espero que la entendáis, la idea es daros una visión del volumen .
Private Sub CommandButton2_Click()
Dim variable As String
numero_de_cables = Application.CountA(Worksheets("Cable list ").Range("a:a"))
' introducir valor de ala
For n = 1 To 2
ala = InputBox("Inicar tamaño de ala", "Título", 100)
If ala <> Empty Then
If ala = 0 Or ala = "" Then
MsgBox "Introducir un valor"
n = 1
Else
n = 2
End If
Else
GoTo final
End If
Next n
Cells(3, 25) = ala
'1º buscar diametro del cable, peso y precio
For ca = 11 To numero_de_cables + 7
pe = InStr(1, Cells(ca, 1), "-pe", vbTextCompare)
n = InStr(1, Cells(ca, 1), "-n", vbTextCompare)
npe = InStr(1, Cells(ca, 1), "-n-pe", vbTextCompare)
If Cells(ca, 7) > 69 Or pe > 1 Or n > 1 Or npe > 1 Then
Cells(ca, 9) = "1x" & Cells(ca, 7)
Else
If Cells(ca, 5) = "SCREENFLEX 110 VC4V-K" Then
Cells(ca, 9) = Cells(ca, 6) & "x" & Cells(ca, 7)
Else
Cells(ca, 9) = Cells(ca, 6) & "G" & Cells(ca, 7)
End If
End If
tipocable = Cells(ca, 9)
modelo = Cells(ca, 5) & "_diam"
modelo1 = Cells(ca, 5) & "_peso"
modelo2 = Cells(ca, 5) & "_precio"
'Hoja comercial cable
Worksheets("Hoja resumen cable").Activate
hor = WorksheetFunction.Match(modelo, ActiveSheet.Range("3:3"), 0)
hor1 = WorksheetFunction.Match(modelo1, ActiveSheet.Range("3:3"), 0)
hor2 = WorksheetFunction.Match(modelo2, ActiveSheet.Range("3:3"), 0)
ver = WorksheetFunction.Match(tipocable, ActiveSheet.Range("a:a"), 0)
If Cells(ca, 7) > 34 And Cells(ca, 7) > 69 Then
Cells(ca, 11) = ((((diam * diam) / 4) * 3.14159265358979) * 1.4) * Cells(ca, 6)
Else
If Cells(ca, 7) > 16 Then
Cells(ca, 11) = ((((diam * diam) / 4) * 3.14159) * 1.4)
Else
Cells(ca, 11) = ((((diam * diam) / 4) * 3.14159) * 1.2)
End If
End If
'distinguir tipo de cable segun su uso
texto = "x"
posicion = InStr(1, Cells(ca, 9), texto, vbTextCompare)
If Cells(ca, 23) = "Communication" Or Cells(ca, 23) = "Instrumentation" Or Cells(ca, 23) = "PControl" Then
Cells(ca, ? = 4
Cells(ca, 16) = 1
Else
If Cells(ca, 7) > 69 And npe = 0 And n = 0 And pe = 0 Then
Cells(ca, ? = 1
Else
If pe > 1 And npe = 0 Then
Cells(ca, ? = 2
Else
If n > 1 Or npe > 1 Then
Cells(ca, ? = 3
Else
If Cells(ca, 7) < 69 Then
Cells(ca, ? = 4
Else
MsgBox " Error nombre de cable linea " & ca & "por favor corrija y vuelva a precalcular"
End If
End If
End If
End If
End If
If Cells(ca, 16) = "" Or Cells(ca, 16) = 0 Then
w = InputBox("Inicar potencia para cable " & Cells(ca, 1), "Título", 1)
Cells(ca, 16) = w
End If
'calculo de area bandeja
If Cells(ca, ? = 1 Then
Cells(ca, 10) = diam * ala * 4.15
Else
If Cells(ca, ? = 2 Then
Cells(ca, 10) = 0
Else
If Cells(ca, ? = 3 Then
Cells(ca, 10) = diam * ala
Else
If Cells(ca, ? = 4 Then
Cells(ca, 10) = ((((diam * diam) / 4) * 3.14159) * 1.3)
Else
MsgBox "Error calculo bandeja, linea " & ca & " por favor corrija y vuelva a precalcular"
End If
End If
End If
End If
Buenas llevo días trabajando sobre una macro la cual realiza varios calculos, obtiene datos, etc. El problema es que cuando la ejecuto excel aparece como no responde. Tarda bastante y no veo que coja todo los recurso del pc. Dicho esto lanzo mis dudas.
*Viendo esta programación creéis que es normal no espero que la entendáis, la idea es daros una visión del volumen .
Private Sub CommandButton2_Click()
Dim variable As String
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
numero_de_cables = Application.CountA(Worksheets("Cable list ").Range("a:a"))
' introducir valor de ala
For n = 1 To 2
ala = InputBox("Inicar tamaño de ala", "Título", 100)
If ala <> Empty Then
If ala = 0 Or ala = "" Then
MsgBox "Introducir un valor"
n = 1
Else
n = 2
End If
Else
GoTo final
End If
Next n
Cells(3, 25) = ala
'1º buscar diametro del cable, peso y precio
For ca = 11 To numero_de_cables + 7
pe = InStr(1, Cells(ca, 1), "-pe", vbTextCompare)
n = InStr(1, Cells(ca, 1), "-n", vbTextCompare)
npe = InStr(1, Cells(ca, 1), "-n-pe", vbTextCompare)
If Cells(ca, 7) > 69 Or pe > 1 Or n > 1 Or npe > 1 Then
Cells(ca, 9) = "1x" & Cells(ca, 7)
Else
If Cells(ca, 5) = "SCREENFLEX 110 VC4V-K" Then
Cells(ca, 9) = Cells(ca, 6) & "x" & Cells(ca, 7)
Else
Cells(ca, 9) = Cells(ca, 6) & "G" & Cells(ca, 7)
End If
End If
tipocable = Cells(ca, 9)
modelo = Cells(ca, 5) & "_diam"
modelo1 = Cells(ca, 5) & "_peso"
modelo2 = Cells(ca, 5) & "_precio"
'Hoja comercial cable
Worksheets("Hoja resumen cable").Activate
hor = WorksheetFunction.Match(modelo, ActiveSheet.Range("3:3"), 0)
hor1 = WorksheetFunction.Match(modelo1, ActiveSheet.Range("3:3"), 0)
hor2 = WorksheetFunction.Match(modelo2, ActiveSheet.Range("3:3"), 0)
ver = WorksheetFunction.Match(tipocable, ActiveSheet.Range("a:a"), 0)
diam = ActiveSheet.Cells(ver, hor) * 1
peso = ActiveSheet.Cells(ver, hor1) * 1
precio = ActiveSheet.Cells(ver, hor2) * 1
Worksheets("cable list ").Activate
Cells(ca, 19) = diam
Cells(ca, 20) = peso
Cells(ca, 19) = precio
'diam2 = diam
'2º calculo de area en ducto
If Cells(ca, 7) > 34 And Cells(ca, 7) > 69 Then
Cells(ca, 11) = ((((diam * diam) / 4) * 3.14159265358979) * 1.4) * Cells(ca, 6)
Else
If Cells(ca, 7) > 16 Then
Cells(ca, 11) = ((((diam * diam) / 4) * 3.14159) * 1.4)
Else
Cells(ca, 11) = ((((diam * diam) / 4) * 3.14159) * 1.2)
End If
End If
'distinguir tipo de cable segun su uso
texto = "x"
posicion = InStr(1, Cells(ca, 9), texto, vbTextCompare)
If Cells(ca, 23) = "Communication" Or Cells(ca, 23) = "Instrumentation" Or Cells(ca, 23) = "PControl" Then
Cells(ca, ? = 4
Cells(ca, 16) = 1
Else
If Cells(ca, 7) > 69 And npe = 0 And n = 0 And pe = 0 Then
Cells(ca, ? = 1
Else
If pe > 1 And npe = 0 Then
Cells(ca, ? = 2
Else
If n > 1 Or npe > 1 Then
Cells(ca, ? = 3
Else
If Cells(ca, 7) < 69 Then
Cells(ca, ? = 4
Else
MsgBox " Error nombre de cable linea " & ca & "por favor corrija y vuelva a precalcular"
End If
End If
End If
End If
End If
If Cells(ca, 16) = "" Or Cells(ca, 16) = 0 Then
w = InputBox("Inicar potencia para cable " & Cells(ca, 1), "Título", 1)
Cells(ca, 16) = w
End If
'calculo de area bandeja
If Cells(ca, ? = 1 Then
Cells(ca, 10) = diam * ala * 4.15
Else
If Cells(ca, ? = 2 Then
Cells(ca, 10) = 0
Else
If Cells(ca, ? = 3 Then
Cells(ca, 10) = diam * ala
Else
If Cells(ca, ? = 4 Then
Cells(ca, 10) = ((((diam * diam) / 4) * 3.14159) * 1.3)
Else
MsgBox "Error calculo bandeja, linea " & ca & " por favor corrija y vuelva a precalcular"
End If
End If
End If
End If
Next ca
final:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True
Application.CutCopyMode = False
End Sub
Por otro lado he pensado si comprara una versión de excel 64 bit podría ir mas rápido? tendría algún tipo de incompactibilidad ??
Un Saludo y a ver que pensáis ustedes.