View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default ComboBox problems !!

Me.ComboBox1.RowSource = Range( _
QUALITYREASONSFORFAILURE). _
Address(1, 1, xlA1, True)

should be

Me.ComboBox1.RowSource = Range( _
"QUALITYREASONSFORFAILURE"). _
Address(1, 1, xlA1, True)

my typo.

--
Regards,
Tom Ogilvy

"Jako " wrote in message
...
I tried the code Tom gave me but now i get the following error.

Runtime Error 1004.

Method "Range of object_global failed".

Please note this the code i am using:

Private Sub CommandButton1_Click()
Dim QUALITYREASONSFORFAILURE
QUALITYREASONSFORFAILURE = NewReasonTextBox.Value

If QUALITYREASONSFORFAILURE < "" Then
Application.ScreenUpdating = False
Sheets("DATA").Activate
With Range(Cells(1, "C"), Cells(Rows.Count, _
"C").End(xlUp))
Set X = .Find(QUALITYREASONSFORFAILURE, , xlValues, xlWhole)
End With
If X Is Nothing Then
Cells(Rows.Count, "C").End(xlUp). _
Offset(1, 0).Select
ActiveCell = QUALITYREASONSFORFAILURE
Range(Cells(1, "C"), _
Cells(Rows.Count, "C").End(xlUp)).Select
ActiveWorkbook.Names.Add Name:="QUALITYREASONSFORFAILURE", _
RefersTo:=Selection
Application.ScreenUpdating = False
Sheets("DATA").Activate
Range("C1").Select
ActiveCell.CurrentRegion.Select
Selection.Sort Key1:=Range("C1"), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Application.ScreenUpdating = True
Me.ComboBox1.RowSource = Range( _
QUALITYREASONSFORFAILURE). _
Address(1, 1, xlA1, True)
Else
Application.ScreenUpdating = True
MsgBox QUALITYREASONSFORFAILURE & " ALREADY EXISTS IN DATABASE"
Application.ScreenUpdating = False
End If
End If
ComboBox1.Value = NewReasonTextBox.Value
NewReasonTextBox.Value = ""

End sub

Thanks


---
Message posted from http://www.ExcelForum.com/