Object Required Error

M

Minitman

Greetings,

I am trying to load the RowSource of a UserForm ComboBox called
"CRefName" with the data on sheet "CustList" from a workbook called
MCL3. For some reason when I try to run this code, I get a

Compile error:
Object required

with the "lMCL_LastRow =" highlighted in the third line.

I don't understand what is missing

Here is the code:
______________________________________________
Option Explicit
Dim i As Integer
Dim lMCL_LastRow As Long
Dim rListMCL As Range
Dim ws1 As Worksheet
______________________________________________

Private Sub UserForm_Initialize()
Set ws1 = Workbooks("MCL3.xls").Worksheets("CustList")
ws1.Activate
Set lMCL_LastRow = ws1.Range("A65536").End(xlUp).Row '<< this line
Set rListMCL = ws1.Range("A2:CB" & lMCL_LastRow)
With CRefName
.RowSource = rListMCL.Address
.ColumnCount = rListMCL.Columns.Count
.ListIndex = 0
End With
End Sub
______________________________________________


Anybody have any idea as to what I am missing?

Any help, suggestion, pointers or links would be greatly appreciated.

Thanks for looking at my question.

-Minitman
 
S

Snake Plissken

try without word "Set" in that line - it seems you just need to give a value
to the variable "lMCL_LastRow"



|
| Here is the code:
| ______________________________________________
| Option Explicit
| Dim i As Integer
| Dim lMCL_LastRow As Long
| Dim rListMCL As Range
| Dim ws1 As Worksheet
| ______________________________________________
|
| Private Sub UserForm_Initialize()
| Set ws1 = Workbooks("MCL3.xls").Worksheets("CustList")
| ws1.Activate
| Set lMCL_LastRow = ws1.Range("A65536").End(xlUp).Row '<< this line
| Set rListMCL = ws1.Range("A2:CB" & lMCL_LastRow)
| With CRefName
| .RowSource = rListMCL.Address
| .ColumnCount = rListMCL.Columns.Count
| .ListIndex = 0
| End With
| End Sub
| ______________________________________________
|
|
| Anybody have any idea as to what I am missing?
|
| Any help, suggestion, pointers or links would be greatly appreciated.
|
| Thanks for looking at my question.
|
| -Minitman
 
M

Minitman

Hey Snake,

That did the trick.

I'll remember that in the future.

Thanks

-Minitman
 

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