Formula to VBA please

  • Thread starter Thread starter Steved
  • Start date Start date
S

Steved

Hello from Steved

How do I please put the below in VBA

for example it converts 2:24 to 1424

=HOUR(C2)*100+MINUTE(C2)

ps yes I've Got Col C:C with about 200 to convert

I Thankyou.
 
Why dont you copy the formula down...

The below code will have the converted value in colD

Sub Macro()
lngLastRow = ActiveSheet.Cells(Rows.Count, "c").End(xlUp).Row
For lngRow = 2 to lngLastRow
Range("D2") = HOUR(Range("C" & lngRow))*100+MINUTE(Range("C" & lngRow))
Next
End Sub

If this post helps click Yes
 
It's hard to say because you didn't tell us where you want the converted
results... back in the same cell or in a different cell. Generally, you
would use this...

Cells(SomeRow, SomeColumn).Value = Format(Cells(2, "C").Value,"hhmm")
 
Back
Top