aggravated

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to enter a number into a cell and have it automatically divide the number by a set number? For example
I enter 10 and want it to divide by 3. Anyone's help would be appreciated.
 
You could have it divide by a power of 10

Tools|options|Edit tab--fixed decimal places

But I don't think that's what you want.

How about putting all your numbers in first.
Then typing the divisor into an empty cell.
Copy that cell
select your range
edit|paste special|check the divide operation.

Another option would be to use a worksheet event macro:

If you want to try this, right click on the worksheet that should have this
behavior and select view code.

Paste this into the code window:

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub

On Error GoTo errHandler:
With Target
If IsNumeric(.Value) Then
Application.EnableEvents = False
.Value = .Value / 3
End If
End With

errHandler:
Application.EnableEvents = True

End Sub

Adjust the range to match what you need:
If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub
 
Put 10 in let's say A1, put 3 in a cell somewhere else, copy the cell with
3,
select A1 and do edit>paste special and check divide. If you want any number
you enter in A1
to be divided by 3 use this macro, right click the sheet tab and paste in
this

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Range("A1"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Value = Target.Value / 3
Application.EnableEvents = True
End Sub



--

Regards,

Peo Sjoblom

Hutch said:
Is it possible to enter a number into a cell and have it automatically
divide the number by a set number? For example:
I enter 10 and want it to divide by 3. Anyone's help would be
appreciated.
 

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

Back
Top