Dividing by fixed number

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
 
D

Don Guillett

try
Sub dividebyformula()
For Each c In Selection
c.Formula = "=" & c & "/3"
Next
End Sub
 
D

Dave O

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
 
C

Colin Macleod

Thanks for this. Exactly what I wanted...


Don Guillett said:
try
Sub dividebyformula()
For Each c In Selection
c.Formula = "=" & c & "/3"
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top