| |

VerySource

 Forgot password?
 Register
Search
View: 2343|Reply: 2

A question about excel vba

[Copy link]

2

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-11 23:00:01
| Show all posts |Read mode
An excel column stores such data as 5:00, 6:00, 7:20, 12:30 and so on. It actually represents time. Now I want to convert all these data into seconds. For example, 7:20 is 7 hours and 20 minutes, which is 7 * 3600 + 20 * 60, please give vba code, thank you! I don't know what function to use to take the substring
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-11 14:30:01
| Show all posts
Dim a
a = Split (Cells (1, 1), ":")
secondtime = 3600 * a (0) + 60 * a (1)
MsgBox secondtime
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-15 18:45:01
| Show all posts
If column A stores the above data:
Sub Zhuanhua ()
    Dim i As Integer
    For i = 1 To [a1] .End (xlDown) .Row
        Cells (i, 1) .Offset (0, 1) = Hour (Cells (i, 1)) * 3600 + Minute (Cells (i, 1)) * 60 + Second (Cells (i, 1))
    Next
End Sub
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list