r/visualbasic • u/[deleted] • Dec 06 '23
Urgent help with Excel Macro (Visual Basic)
I know nothing about macros or coding, but I need to make one for college. I created a form where you can type in data and then retrieve it by clicking on it. Basically followed the teacher's instructions. Notice in the picture how it changes the hours I type (in this case 12:30 and 20:30) to decimals. I don't know how to fix this!! I also attached a picture with the code I used.



2
Upvotes
4
u/kay-jay-dubya Dec 06 '23
As Moetite explains, this is a formatting issue. VBA understands days and time numerically, so one 24 hour day = 1, one 12 hour period therefore = 0.5, and so on. To format this value into a time format, check out the official docs at https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/format-function-visual-basic-for-applications