Calcular fórmulas y pasar resultados a otra hoja

Para DanteAmor

Me gustaría poder conseguir realizar estas fórmulas de cálculos para los sectores zaragoza y walqa:

Hay que tener en cuenta que en un futuro puede que se amplíe el número de volúmenes de los sectores y que algunos datos de la columna "libre" están en TB (terabytes) y el resultado sería bueno colocarlo en GB (gigabytes). Si necesitas más información me dices y te amplio.

Respuesta
1

H o l a: me puedes enviar un correo nuevo y me explicas con ejemplos cómo debo realizar el cálculo. R ecuerda poner tu nombre de usuario en el asunto.

¡Muchísimas Gracias! 

Perfecto Dante, te envío ejemplo al correo. Un saludo!

Te anexo la macro

Sub SetorZaragoza()
'Por.Dante Amor
    Dim filas()
    Dim sectores()
    Set h1 = Sheets("DATOS")
    Set h2 = Sheets("RESUMEN")
    '
    'Buscar fecha en datos
    Set b = h1.Rows(1).Find("-", lookat:=xlPart)
    If Not b Is Nothing Then
        fecha = CDate(b.Value)
    Else
        Set b = h1.Rows(1).Find("/", lookat:=xlPart)
        If Not b Is Nothing Then
            fecha = CDate(b.Value)
        Else
            fecha = Date
        End If
    End If
    '
    'Buscar fecha en Resumen
    Set b = h2.Rows(1).Find(fecha, lookat:=xlWhole)
    If Not b Is Nothing Then
        col = b.Column
    Else
        col = h2.Cells(1, Columns.Count).End(xlToLeft).Column + 1
        h2.Cells(1, col) = fecha
    End If
    '
    'Buscar sectores
    bsectores = Array("ZARAGOZA", "WALQA")
    n = 0
    Set r = h1.Columns("A")
    For k = LBound(bsectores) To UBound(bsectores)
        Set b = r.Find(bsectores(k), lookat:=xlPart)
        If Not b Is Nothing Then
            Celda = b.Address
            Do
                n = n + 1
                ReDim Preserve filas(n)
                ReDim Preserve sectores(n)
                filas(n) = b.Row
                sectores(n) = b.Value
                Set b = r.FindNext(b)
            Loop While Not b Is Nothing And b.Address <> Celda
        End If
    Next
    '
    'Pasar Datos
    For i = 1 To n
        wn = 0
        vtot = 0
        vvol = 0
        fila = filas(i)
        dato = h1.Cells(fila, "A")
        If InStr(1, LCase(dato), "zaragoza") > 1 Then
            w1 = 6: w2 = 4
        Else
            w1 = 1: w2 = 2
        End If
        ufila = h1.Cells(fila + w1, "C").End(xlDown).Row
        For j = fila + w2 To ufila
            Select Case h1.Cells(j, "C")
            Case "/mnt/logs":                                vlog = h1.Cells(j, "A")
            Case "/mnt/vols/vol_C000", "/mnt/vols/vol_B000": v000 = h1.Cells(j, "A")
            Case "/mnt/mensajes":                            vmen = h1.Cells(j, "A")
            Case Else
                If IsNumeric(h1.Cells(j, "B")) And h1.Cells(j, "B") <> "" Then
                    wn = wn + 1
                    vtot = vtot + h1.Cells(j, "B") * 100
                End If
                If h1.Cells(j, "A") <> "" Then
                    vlibre = Replace(h1.Cells(j, "A"), "G", "")
                    If IsNumeric(vlibre) Then
                        vvol = vvol + Val(vlibre)
                    End If
                End If
            End Select
        Next
        '
        sector = sectores(i)
        Set b = h2.Columns("A").Find(sector, lookat:=xlWhole)
        If Not b Is Nothing Then
            fil = b.Row
        Else
            fil = h2.Range("A" & Rows.Count).End(xlUp).Row + 2
        End If
        '
        h2.Cells(fil, "A") = sector
        h2.Cells(fil + 1, "A") = "LIBRE VOL LOG"
        h2.Cells(fil + 2, "A") = "LIBRE VOL 0"
        h2.Cells(fil + 3, "A") = "LIBRE VOL MENSAJES"
        h2.Cells(fil + 4, "A") = "% TOTAL OCUPADO EN VOLUMENES"
        h2.Cells(fil + 5, "A") = "FREESPACE EN VOLUMENES"
        '
        h2.Cells(fil + 1, col) = vlog
        h2.Cells(fil + 2, col) = v000
        h2.Cells(fil + 3, col) = vmen
        h2.Cells(fil + 4, col) = vtot / wn
        h2.Cells(fil + 5, col) = vvol
    Next
    MsgBox "fin"
End Sub

sal u dos

¡Muchísimas Gracias! 

He hecho una pequeña prueba y va perfecto! Voy a seguir haciendo pruebas pero creo que va perfecto todo, eres un maestro!

Un fuerte abrazo

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas