PDA

View Full Version : Default Value in Combobox



phendrena
01-21-2009, 02:58 AM
Hi there,

I have the following code
Private Sub UserForm_Initialize()
Set ws = Worksheets("Lookups")
Me.StartUpPosition = 0
Me.Top = 125
Me.Left = 125
Me.Width = 365
Me.Height = 396.75
Me.DSTHeader.Width = 365
cboWhoCalled.List = WorksheetFunction.Transpose(ws.Range("WhoCalled"))
cboReason.List = WorksheetFunction.Transpose(ws.Range("CallReason"))
cboSubject.List = WorksheetFunction.Transpose(ws.Range("EmailSubject"))
cboScheme.List = WorksheetFunction.Transpose(ws.Range("Scheme"))
cboSendTo.List = WorksheetFunction.Transpose(ws.Range("Destination"))

Me.txtDate.Value = Format(Date, "yyyy/mm/dd")
Me.txtTime.Value = Time
Me.txtCM.Value = Application.UserName
Me.txtCM.SetFocus
cmdUpdate.Enabled = True
End Sub

This all works fine, however, i now want to set the field cboSendTo to a default value. The value will be taken from the singel cell range named "SupportCM". For the life of me i can't get the field to default to that value.

I've attached the workbook, and there are other references to this field that also change the value. I've tried adding the following into the above

Set des = ws.Range("SupportCM")
cboSendTo.Value = des


and changing the various references to cbSendTo accordingly, but no joy.

Any suggestions?

Thanks,

Bob Phillips
01-21-2009, 03:30 AM
The value is a string or number, not an object, so don't Set it



des = ws.Range("SupportCM").Value
cboSendTo.Value = des

phendrena
01-21-2009, 05:58 AM
Hi xld,

Maybe i'm just being a bit think, but i can't get it to work :-
Private Sub UserForm_Initialize()
Set ws = Worksheets("Lookups")
des = ws.Range("SupportCM").Value
Me.StartUpPosition = 0
Me.Top = 125
Me.Left = 125
Me.Width = 365
Me.Height = 396.75
Me.DSTHeader.Width = 365
cboWhoCalled.List = WorksheetFunction.Transpose(ws.Range("WhoCalled"))
cboReason.List = WorksheetFunction.Transpose(ws.Range("CallReason"))
cboSubject.List = WorksheetFunction.Transpose(ws.Range("EmailSubject"))
cboScheme.List = WorksheetFunction.Transpose(ws.Range("Scheme"))
cboSendTo.List = WorksheetFunction.Transpose(ws.Range("Destination"))

Me.txtDate.Value = Format(Date, "yyyy/mm/dd")
Me.txtTime.Value = Time
Me.txtCM.Value = Application.UserName
Me.txtCM.SetFocus
Me.cboSendTo.Value = des
cmdUpdate.Enabled = True
End SubPlus i've amended all the other references to = des also.

phendrena
02-05-2009, 03:29 AM
Anyone able to provide further assistance with this one please?

Thanks,