A Userform goodie - updating records
Zani,
You can use FORMAT to get the data correct. In the xample below, I
ssume Range("A1") to contain time in format hh:mm e.g. 12:30 in textbox
Private Sub UserForm_Initialize()
TextBox1.Value = Format(ThisWorkbook.Sheets("Sheet1").Range("a1"), "HH:MM")
End Sub
I I understand your requirement about positioning the listox(es), you could
store the value of LISTINDEX for each box and in the UserForm_Initialize
module set LISTINDEX to stored value.
Private Sub UserForm_Initialize()
TextBox1.Value = Format(ThisWorkbook.Sheets("Sheet1").Range("a1"), "HH:MM")
ListBox1.ListIndex = Range("C1") <=== Set ListIndex
End Sub
Private Sub ListBox1_Click()
Range("C1") = ListBox1.ListIndex <== Saved in C1
End Sub
HTH
"Zani" wrote:
I also have a slight problem returning times from the data in the spreadsheet
back to the userform - they show as numbers rather than the original 24 hr
clock.
--
Zani
(if I have posted here, I really am stuck!)
"JakeyC" wrote:
If it's set up as I think you describe (a spreadsheet containing all
the info for a record number along that same row), then simply reverse
the process.
When you write the data to the user form, you've probably got a button
that runs a macro to transfer the data to the cells from your textboxes
such as
Sheets("Data").Cells(14,37).Value = UserForm1.TextBox1.Text (or
similar).
To get the data back to the userform, just reverse the statement and
place it in a suitable event module:
UserForm1.TextBox1.Text = Sheets("Data").Cells(14,37).Value
|