Copy 7-8 digits and paste as HH:MM:SS

Yugo101

New Member
Joined
Jun 12, 2017
Messages
27
This is my issue. I have a VBA set up and copies date from one workbook to another, but on the target spreadsheet the time is display as for example 10231012 which means 10:23:10 HH:MM:SS or if single digit time 9231012 is 09:23:10. So the How can I copy the numbers and paste as HH:MM:SS. any solution I will convert to my columns etc.

Many Thanks
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Code:
Public Function ConvertTime(n As Long) As Date
    ConvertTime = Format(n \ 100, "00\:00\:00")
End Function
 
Upvote 0
Code:
Public Function ConvertTime(n As Long) As Date
    ConvertTime = Format(n \ 100, "00\:00\:00")
End Function
Sorry. How would I input this into my VBA code?. I tried doing by it self but asks to run macro.
 
Upvote 0
Can you share your code?
Pretty much how it looks, may not be exact.

So I press command button, file explorer opens, click the workbook I want then it copies the A column which is the 7-8 digits.

Dim FileToOpen As Variant
Dim OpenBook As Workbook
Dim Last As Long
Application.ScreenUpdating = False
FileToOpen = Application.GetOpenFilename (Title:”Workbook”, FileFilter:="Excel Files(*.xls*),*xls*")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks. Open(FileToOpen)
Last = OpenBook.Sheets (1). Range (“A” & Rows.Count). End(xlUp) .Row
OpenBook.Sheets (1). Range("A:A” & Last).Copy
ThisWorkbook. Worksheets(“Sheet01).Range("A" & Rows.Count).End(x1Up).Offset(1, 0). PasteSpecial xlPasteValves
OpenBook.Close False
End IF
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,086
Messages
6,123,038
Members
449,092
Latest member
ikke

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