Sie sind auf Seite 1von 1

MACRO VBA: SUMAR UN RANGO DE CELDAS

SELECCIONADAS
Crear una macro que nos sume un rango de celdas seleccionado.
Sub sumar_rango()

'Para recorrer el rango
Dim micelda As Range, z As Boolean

'Recorro las celdas
For Each micelda In Selection
'Compruebo si la celda contiene texto
If WorksheetFunction.IsText(micelda) Then
z = True
End If
Next micelda

If z = True Then
valor = MsgBox("Hay texto en el rango seleccionado" & vbCrLf &
"Deseas continuar?", vbYesNo)
If valor = vbYes Then
MsgBox WorksheetFunction.Sum(Selection)
Else
MsgBox " No se ha realizdo la suma"
End If
End If

End Sub

Das könnte Ihnen auch gefallen