I have a Column that stores a cumulative time value as 95:31:00 (for example) that is of the format [h]:mm:ss. I am needing to convert this to a Text / String value which i know can be done using the worksheet function Text(timeval, "[hh]:mm:ss"), but i am curious if the same can be accomplished programmatically using VBA. I have the following code but it keeps inserting the value as a datetime format instead of a string? The Timestring is not returning as an actual string value capturing the values as "[hh]:mm:ss". What am i Doing Wrong?
Sub DataCleanse() Dim RowNum As Long Dim CpH As Double Dim StatDate As Date Dim EomFlag As Integer Dim TimeString As String StatDate = "05/22/2020" EomFlag = 0 RowNum = 2 For RowNum = 2 To 19 CpH = Round(Cells(RowNum, 13).Value / (Cells(RowNum, 11).Value * 24), 2) TimeString = WorksheetFunction.Text(Cells(RowNum, 11), "[h]:mm:ss") Cells(RowNum, 15).Value = CpH Cells(RowNum, 16).Value = StatDate Cells(RowNum, 17).Value = EomFlag Cells(RowNum, 33).Value = TimeString Next RowNum End Sub