• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Run-time error 91

josros

New Member
Hi,
I have the following code giving this error " run-time error 91,

Code:
 Private Sub CommandButton1_Click()
Dim cll As Range


Set rng = Sheet1.Range("SAGEID")
    ' Find the selected list item value in the data range
    
    Set cll = rng.Columns(1).Find(ListBox_Results.Value, rng.Cells(1, 1), xlValues)
        ' First column is the lookup range, so we don't update it but the others
    
                
  cll.Cells(, 2).Value = TextBox_Results1.Value
  cll.Cells(, 3).Value = TextBox_Results2.Value
  cll.Cells(, 13).Value = TextBox_Results3.Value
  cll.Cells(, 10).Value = TextBox_Results4.Value
  cll.Cells(, 14).Value = TextBox_Results5.Value
  cll.Cells(, 4).Value = TextBox_Results6.Value
  cll.Cells(, 5).Value = TextBox_Results8.Value
  cll.Cells(, 6).Value = TextBox_Results9.Value
  cll.Cells(, 11).Value = TextBox_Results10.Value
  cll.Cells(, 12).Value = TextBox_Results11.Value
  cll.Cells(, 8).Value = TextBox_Results12.Value
  cll.Cells(, 15).Value = TextBox_Results13.Value
  cll.Cells(, 16).Value = TextBox_Results14.Value
  cll.Cells(, 9).Value = TextBox_Results15.Value
  cll.Cells(, 7).Value = TextBox_Results16.Value
  cll.Cells(, 1).Value = TextBox_Results17.Value

end sub

thank you,
 
Probably because the value wasn't found, try:
Code:
Private Sub CommandButton1_Click()
Dim cll As Range

Set rng = Sheet1.Range("SAGEID")
' Find the selected list item value in the data range
    
Set cll = rng.Columns(1).Find(ListBox_Results.Value, rng.Cells(1, 1), xlValues)
' First column is the lookup range, so we don't update it but the others
If cll Is Nothing Then
  MsgBox "'" & ListBox_Results.Value & "' not found"
Else
  cll.Cells(, 2).Value = TextBox_Results1.Value
  cll.Cells(, 3).Value = TextBox_Results2.Value
  cll.Cells(, 13).Value = TextBox_Results3.Value
  cll.Cells(, 10).Value = TextBox_Results4.Value
  cll.Cells(, 14).Value = TextBox_Results5.Value
  cll.Cells(, 4).Value = TextBox_Results6.Value
  cll.Cells(, 5).Value = TextBox_Results8.Value
  cll.Cells(, 6).Value = TextBox_Results9.Value
  cll.Cells(, 11).Value = TextBox_Results10.Value
  cll.Cells(, 12).Value = TextBox_Results11.Value
  cll.Cells(, 8).Value = TextBox_Results12.Value
  cll.Cells(, 15).Value = TextBox_Results13.Value
  cll.Cells(, 16).Value = TextBox_Results14.Value
  cll.Cells(, 9).Value = TextBox_Results15.Value
  cll.Cells(, 7).Value = TextBox_Results16.Value
  cll.Cells(, 1).Value = TextBox_Results17.Value
End If
End Sub
 
Thank you for the reply.

But what I am looking to be able to edit or add new vendor through the userform and update the cells on the spreadsheet when click update button (attaching the file, there's a search button that will open the userform, much appreciated your help.
 

Attachments

  • VENDORS.xlsm
    144.4 KB · Views: 1
But what I am looking to be able to edit or add new vendor through the userform and update the cells on the spreadsheet when click update button
That's something entirely different.
Someone else may be willing to help.
 
Back
Top