UserForm Initialization

P

Patrick Simonds

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
 
T

Tom Ogilvy

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top