VBA: Timecode to frames and back w/ variable frame rate.

Joe91042

New Member
Joined
Aug 4, 2011
Messages
8
I have modified the below functions from an earlier thread to be able to change the frame rate in one spot within the function. I would like to be able to point to a second cell that contains the frame rate while the first cell contains the TC or frames. Not sure how to execute that. The cell would maybe look like [TC2Frames(A1,A2)] with A1 being the TC number and A2 being the Frame rate.


Function TC2Frames(TimeCodeCell As Range) As Long

Dim hh As Long
Dim mm As Long
Dim ss As Long
Dim ff As Long
Dim TimeCodeText As String
Dim FrameRate As Integer

TimeCodeText = TimeCodeCell.Value
FrameRate = 29.97

hh = Mid(TimeCodeText, 1, 2)
mm = Mid(TimeCodeText, 4, 2)
ss = Mid(TimeCodeText, 7, 2)
ff = Mid(TimeCodeText, 10, 2)

TC2Frames = ff + (ss * FrameRate) + (mm * FrameRate * 60) + (hh * FrameRate * 60 * 60)
End Function

Function Frames2TC(NumFramesValue As Long) As String

Dim hh As Long
Dim mm As Long
Dim ss As Long
Dim ff As Long
Dim FrameRate As Integer

FrameRate = 25

hh = Int(NumFramesValue / FrameRate / 60 / 60)
mm = Int((NumFramesValue - (hh * FrameRate * 60 * 60)) / FrameRate / 60)
ss = Int((NumFramesValue - (hh * FrameRate * 60 * 60 + mm * FrameRate * 60)) / FrameRate)
ff = Int(NumFramesValue - (hh * FrameRate * 60 * 60 + mm * FrameRate * 60 + ss * FrameRate))

Frames2TC = Format(hh, "00") & ":" & Format(mm, "00") & ":" & Format(ss, "00") & ":" & Format(ff, "00")
End Function



With this function I can build a Timecode coversion worksheet as well as the difference function from the earlier thread. I think?

Thanks
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,224,520
Messages
6,179,270
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top