Dividing input by a constant

  • Thread starter Thread starter BabyBlueAXiD
  • Start date Start date
B

BabyBlueAXiD

Is there a way to create a formula or macro that when I enter a number in a
cell it will automatically divide 5.7?
 
Hi,

Right click the sheet tab, View code and paste this in. Change the range to
suit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then' change to suit
If IsNumeric(Target) Then
On Error Resume Next
Application.EnableEvents = False
Target = Target / 5.7
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End Sub

Mike
 
THAT WORKS PERFECT!Thanks so much!

Mike H said:
Hi,

Right click the sheet tab, View code and paste this in. Change the range to
suit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then' change to suit
If IsNumeric(Target) Then
On Error Resume Next
Application.EnableEvents = False
Target = Target / 5.7
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End Sub

Mike
 

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