Format date and time in Excel with VBA



Format date and time in Excel with VBA
Copy data and time values from one sheet to the other
Format time values to suit your needs with VBA. Format time values in Excel with VBA

Sub formating()

Worksheets(“sheet1”).Select
Sheets(“sheet1”).Range(“A2:B23”).Copy Destination:=Sheets(“sheet2”).Range(“A2:B23”)
Worksheets(“sheet2”).Select

‘Date Column
ActiveSheet.Columns(“a:a”).Select
Selection.NumberFormat = “m/d/yyyy”

‘Time Column
ActiveSheet.Columns(“b:b”).Select
Selection.NumberFormat = “hh:mm:ss”

End Sub

For more help visit my website

I am able to provide online help on your computer for a reasonable rate.

MY videos are all created on Camtasia.

Follow me on Facebook

Watch more new videos about Excel Office | Synthesized by Mindovermetal English

Rate this post

Bài viết liên quan

Theo dõi
Thông báo của
guest
3 Comments
Cũ nhất
Mới nhất Được bỏ phiếu nhiều nhất
Phản hồi nội tuyến
Xem tất cả bình luận
PATRICIA PETRI

Amazing video. thank you for sharing.

Ka Aa

Great Video!!!. I have many ranges in a form. i want to color the cell to show that are required. if the cell has data, no color but if the cell is blank, color the cell. Also, I want to format a number to a date (like access)? if I enter a number 121519, it will give me 12/15/19 or If I enter 12/15/19 it will give me the same things.. Thanks in advance.

mizouman

very handy , thank you for sharing it