Formula to VBA please

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.
 
J

Jacob Skaria

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
 
R

Rick Rothstein

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")
 

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

Top