![]() |
UserForm Initialization
Any ideas why the code below would not work. The referenced cell (1,13) will
either be blank, show 00:30 or 01:00. These values were placed in the cell with the following code: Dim lngValue 'As Long If OptionButton1.Value Then lngValue = "" If OptionButton2.Value Then lngValue = TimeSerial(0, 30, 0) If OptionButton3.Value Then lngValue = TimeSerial(0, 60, 0) rng(1, 13).Value = lngValue Private Sub UserForm_Initialize() Dim rng Set rng = Cells(ActiveCell.Row, 1) With ActiveCell.Offset(1, 13) If .Value = "" Then OptionButton1.Value = True ElseIf .Value = TimeSerial(0, 30, 0) Then OptionButton2.Value = True ElseIf .Value = TimeSerial(0, 60, 0) Then OptionButton3.Value = True End If End With End Sub |
UserForm Initialization
TimeSerial returns a double. Since your variable name is LngValue, I
expect it is dimmed as Long and is the source of your problem (it returns zero for either TimeSerial value). -- Regards, Tom Ogilvy "Patrick Simonds" wrote in message ... Any ideas why the code below would not work. The referenced cell (1,13) will either be blank, show 00:30 or 01:00. These values were placed in the cell with the following code: Dim lngValue 'As Long If OptionButton1.Value Then lngValue = "" If OptionButton2.Value Then lngValue = TimeSerial(0, 30, 0) If OptionButton3.Value Then lngValue = TimeSerial(0, 60, 0) rng(1, 13).Value = lngValue Private Sub UserForm_Initialize() Dim rng Set rng = Cells(ActiveCell.Row, 1) With ActiveCell.Offset(1, 13) If .Value = "" Then OptionButton1.Value = True ElseIf .Value = TimeSerial(0, 30, 0) Then OptionButton2.Value = True ElseIf .Value = TimeSerial(0, 60, 0) Then OptionButton3.Value = True End If End With End Sub |
All times are GMT +1. The time now is 02:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com