Converting a cell to minutes

P

Plusone

Hello

I need to enter a number of hours into a cell and it will work out the
amount in minutes. Obviously i could do this with a calculation in
another cell (=sum(A1*60)...

However i need it to work it out in the cell that i put the number of
hours in. For example i will enter 2 and it will change it to 180.

Is this possible?

Kind Regards,
Darren Stewart
 
S

Scoops

Plusone said:
Hello

I need to enter a number of hours into a cell and it will work out the
amount in minutes. Obviously i could do this with a calculation in
another cell (=sum(A1*60)...

However i need it to work it out in the cell that i put the number of
hours in. For example i will enter 2 and it will change it to 180.

Is this possible?

Hi Darren

Right-click the sheet tab > View Code.
This will open the vb editor, paste the code below into window headed
"General" and "Declarations":

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Column = 1 Then Target = Target * 60
Application.EnableEvents = True
End Sub

The macro checks to see if the cell changed is in column 1 (A) and then
multiplies it by 60 if it was.

Amend the column (or .Row) as you need it.

The EnableEvents prevents the macro firing again when it enters the new
figure.

And, hopefully, you'll find that 2 = 120 ;-)

Regards

Steve
 
S

Scoops

Scoops said:
Application.EnableEvents = False
If Target.Column = 1 Then Target = Target * 60
Application.EnableEvents = True
End Sub
If you're only concerned with one cell, this might be better:

If Target.Address = "$A$1"

Amend as necessary.

Regards

Steve
 
Top