ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formula to VBA please (https://www.excelbanter.com/excel-programming/430204-formula-vba-please.html)

Steved

Formula to VBA please
 

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.

Jacob Skaria

Formula to VBA please
 

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
---------------
Jacob Skaria


"Steved" wrote:

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.


Rick Rothstein

Formula to VBA please
 

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

--
Rick (MVP - Excel)


"Steved" wrote in message
...
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.




All times are GMT +1. The time now is 03:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com