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

Yugo101

New Member
Joined
Jun 12, 2017
Messages
32
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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Code:
Public Function ConvertTime(n As Long) As Date
    ConvertTime = Format(n \ 100, "00\:00\:00")
End Function
 
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,223,958
Messages
6,175,633
Members
452,661
Latest member
Nonhle

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