Excel Mileage Form

  Graham. 12:37 20 Feb 08

I have Miles in column C, Cost in Column D at 15.5 pence per mile. I need a Macro to automatically enter Cost, please.

  VoG II 12:44 20 Feb 08

Right click the sheet tab, View Code. Copy and paste in

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 Then
Application.EnableEvents = False
Target.Offset(0, 1).Value = Target.Value * 0.155
Target.Offset(0, 1).NumberFormat = "$#,##0.00"
Application.EnableEvents = True
End If
End Sub

then close the code window.

  Graham. 13:36 20 Feb 08

Not working as expected. There was some text already there, I deleted it and pasted yours. Should I be able to click a cell in column D for the calculation to be made?
At the top of the Code window, I have Worksheet and Change.

  VoG II 13:41 20 Feb 08

If you enter a mileage in a cell in column C the macro will put the cost into the same row in column D.

Don't worry about the Worksheet and Change at the top, although if you click the arrow to the right of Change you'll see the other exciting event procedures that are available :o)

  Graham. 13:46 20 Feb 08

OK, it's working now. I had to re-enter the existing data. Thanks again.

This thread is now locked and can not be replied to.

Nintendo Switch review: Hands-on with the intuitive modular console and its disappointing games…

1995-2015: How technology has changed the world in 20 years

This abstract video touches on division in our technologic world

Best alternatives to iTunes for Mac | Best music players for macOS: Free your music from the…