I have a userform (Userform1) that has a textbox (TextBox2) that is a time field ideally formatted to hh/mm am/pm. It is stored in a sheet (“Schedule”) in ColumnB.
I need to format both the data in the sheet and the userform.
I have a function that when the user clicks a button, the data from the userform will be added to appropriate row (varRow) in the Schedule spreadsheet. I also have a function that loads the selected row data (varRow) from the spreadsheet into the form. These need the time data to be formatted as a time hh mm am/pm for both loading into the userform from the spreadsheet and exporting from the userform into the spreadsheet.
Oh and just to complicated matters more, I also load data from a different spreadsheet into a listbox on UserForm1. The time would need to be formatted here too. I included code here because I suspect I just need to tweek the following line (ListBox1.List(x, 1) = Cells(lr, "B") a bit
I just can’t seem to get anything I have tried to work. Ideas anyone?
I hate date/times. They are a constant headache.
As usual, many thanks to all the helpful Excel VBA gurus.
I need to format both the data in the sheet and the userform.
I have a function that when the user clicks a button, the data from the userform will be added to appropriate row (varRow) in the Schedule spreadsheet. I also have a function that loads the selected row data (varRow) from the spreadsheet into the form. These need the time data to be formatted as a time hh mm am/pm for both loading into the userform from the spreadsheet and exporting from the userform into the spreadsheet.
Oh and just to complicated matters more, I also load data from a different spreadsheet into a listbox on UserForm1. The time would need to be formatted here too. I included code here because I suspect I just need to tweek the following line (ListBox1.List(x, 1) = Cells(lr, "B") a bit
Code:
deg2 = TextBox1.value
Sheets("Classes").Activate
For lr = 2 To Cells(65536, "A").End(xlUp).Row
Set deg1 = Cells(lr, "A")
If deg1 = deg2 Then
ListBox1.AddItem
ListBox1.List(x, 0) = Cells(lr, "A")
ListBox1.List(x, 1) = Cells(lr, "B")
ListBox1.List(x, 2) = Cells(lr, "C")
ListBox1.List(x, 3) = Cells(lr, "D")
ListBox1.List(x, 4) = Cells(lr, "E")
ListBox1.List(x, 5) = Cells(lr, "F")
ListBox1.List(x, 6) = lr
x = x + 1
End If: Next
I just can’t seem to get anything I have tried to work. Ideas anyone?
I hate date/times. They are a constant headache.
As usual, many thanks to all the helpful Excel VBA gurus.
Last edited: