Range Problem - Worksheet Failed

manzetti

New Member
Joined
Apr 19, 2009
Messages
13
Here's what I'm doing... I have a combo box (called ClientListBox) that displays 2 columns, Column A (which is a unique id) & Column B (client's name) when they select the item, the click event should populate all the fields on the user form. Here's the code:

Private Sub ClientComboBox_Change()
Dim strFind
Dim xSearch As Range
Set xSearch = Sheets("ClientSpreadsheet").Range("a2", Range("a65536").End(xlUp))
Dim f As Integer
strFind = Me.ClientComboBox.Value
If strFind <> "" Then
With xSearch
Set C = .Find(strFind, LookIn:=xlValues)
If Not C Is Nothing Then
C.Select
With Me 'load entry to form
Me.text1.Value = ...
Me.text2.Value = ...
Me.text3.Value = ...
End With
End If
End With
Else
MsgBox "Select a Client"
End If
End Sub

It worked initially, now all I ever get is runtime error 1004 - RANGE OF OBJECT WORKSHEET FAILED.

When I walk through my code it fails at

Set xSearch = Sheets("ClientSpreadsheet").Range("a2", Range("a65536").End(xlUp))

I could use another pair of eyes. What I am I doing wrong?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Try:

Code:
Set xSearch = Sheets("ClientSpreadsheet").Range("A2:A" & Range("a65536").End(xlUp).Row)

If it doesn't work, then we'll look deeper.
 
Upvote 0
Code:
With Sheets("ClientSpreadsheet")
    Set xSearch = .Range("a2", .Range("a65536").End(xlUp))
End With
 
Upvote 0
I started over i.e. created a new spreadsheet and copied over the userform and modules. I'm no longer get this error and everything works.

Thanks for your responses.
 
Upvote 0

Forum statistics

Threads
1,215,758
Messages
6,126,698
Members
449,331
Latest member
smckenzie2016

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top