compile error on a listbox

gjp55

New Member
Joined
Mar 31, 2011
Messages
34
I have some code that has an active X listbox passed into a function.
This works fine once the spreadsheet is open (function is called from a button click) but I would like the function to be called as soon as the spreadsheet is opened up without user interaction.

The problem I have is I get a compile error as the spreadsheet opens up - "ByRef argument type mismatch" with the listbox name highlighted in the code.

Does anybody know how to fix this ?

Thanks


Private Sub Workbook_Open()

Sheet1.Activate
Sheet1.Select

PopulateListBox "sp_getsp1", 5, ListBox1
'param 1 is the sp name being called
'param 2 is a cell reference where the data from the sp is being dumped
'param 3 is the name of the listbox being populated

End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hard to say without seeing the function/sub PopulateListbox and/or knowing what type of listbox it is.

Is it on a worksheet? A userform?
 
Upvote 0
Hi, its an activex list box and the function excpects a msforms.listbox as a parameter.
What is strange is that once the spreadsheet is open, I can call the same function (with the same parameters) and it works fine.

function expects

Public Sub AllNewCode(spName As String, CellStart As Single, ListBox As MSForms.ListBox)

......code
 
Upvote 0

Forum statistics

Threads
1,224,541
Messages
6,179,418
Members
452,912
Latest member
alicemil

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