Dividing by fixed number

  • Thread starter Thread starter Colin Macleod
  • Start date Start date
C

Colin Macleod

I want to replace a number of cells on a worksheet with new values. These
new values will be the existing value divided by 0.8775. I realise I can do
this by using Edit>Paste Special>Divide - but I want to be able to see the
division in the Formula Bar rather than just the end value. At the moment,
I'm just going through on a cell-by-cell basis, and editing each one by
hand. Is there a quicker way to do this?

Thanks
 
try
Sub dividebyformula()
For Each c In Selection
c.Formula = "=" & c & "/3"
Next
End Sub
 
Good morning, Colin-
Copy this bit of code and paste it in as a macro in your spreadsheet.
It modifies each formula in a range that you highlight and performs
that division you need.

Sub DivideBy()
Dim rCell As Range

For Each rCell In Selection.Cells
If Mid(rCell.Formula, 1, 1) <> "=" Then rCell.Formula = "=" &
rCell.Formula
rCell.Formula = "=(" & Right(rCell.Formula, Len(rCell.Formula) - 1)
& ")/.8775"
Next rCell

End Sub
 
Back
Top