Hi All
I have a Userform that has become quite complex. The problem I am having is this:
Two of the elements of the form are a Start Time and Date. I need the form to accept the input as 06021400 ie mmddhhmm.
Then for this to translate into the Excel Sheet to display just hh:mm.
Is there any way I can do this. I have tried a multitude of things, the last being:
"VariableName = Format(Date, "mmddhhmm")"
however had no joy
Please help if possible.
Thanks
Matt
Hello Matt,
When you say "Userform" Are you referring to a worksheet or a VBA UserForm?
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Sorry, should have said that.
VBA UserForm, which then puts the data into a worksheet
Hello peakymatt,
Assuming your initial value "06021400" was input using a text box, you can simply remove the hours and minutes portion using string functions like this...
Dim myTime As String myTime = Right(TextBox1.Value, 4) 'Remove this line if you don't want the colon myTime = Left(myTime, 2) & ":" & Right(myTime, 2) 'myTime = "14:00" Range("A1").Value = myTime
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Hi thanks for that
I must be doing something wrong. I have added the code to my UserForm
and when I enter the value in the textbox and submit the form all I get back in the Spreadsheet is "#########.
Any ideas??
Hi Further to my last
Have got it to returna result, the entry detail was "02061900" the result was "10190000". Any ideas how I can get the output to be the same as the input, with the output tio display just as hh:mm.
Thanks
Hello peakymatt,
I think I should have a look at your workbook. Can you post a copy for me?
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
The work is on a secure system, so can't actually send it. Will try and do up a dummy to replicate my problem.
Stand by, and thanks again
Hi Again
Here we go. This will give you an idea of what I am trying to achieve.
Person ID in Col A, Start Time in Col B, Stop Time in Col C. Then as you can see there is a days worth of times across the top, set up in 30 min increments. When the times are entered from the Form they go into COL B and COL C, and then it is conditionally formatted over the time period. Dates for the times has to be current date, then when it clocks over midnight the date is obviously tomorrow.
All data is on the sheet named timeline. Activate the form by the button towards the bottom
Hopefully you can help
Thanks
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks