Tilen Rupar
Tilen Rupar

Reputation: 1

VBA: Subtracting a cell from an active cell value

I have this solution, but i would like to print a formula for it.

Sub Minus()

    ActiveCell = ActiveCell - ActiveCell.Offset(0, -1) 

End Sub

This code returns only correct value, but i would like full original value minus adjacent cell.

Thanks!

Upvotes: 0

Views: 734

Answers (1)

Scott Holtzman
Scott Holtzman

Reputation: 27249

Sub Minus()

    With ActiveCell
        .Formula = "=" & .Value & "-" & .Offset(0, -1).Value
    End With

End Sub

Upvotes: 4

Related Questions