PDA

View Full Version : Solved: Userform not opening with a Button



simora
01-10-2011, 10:59 PM
When I try to open a UserForm, I get a Run-time error '380'

If I move the button to open the Userform to the worksheet "States" everything works fine.
How do I modify the code so that it works even when the button is on another Worksheet?

This is the code I use to try to open the UserForm


Sub DNewClientForm()
NewClientForm.Show
End Sub


NewClientForm.Show is highlighted as the error point.

This is the initialize code


Private Sub UserForm_Initialize()
ComboBox12.RowSource = Range("States").Range("F2", Range("F65536").End(xlUp)).Address
Set RowSource = Range(ComboBox12.RowSource)
End Sub

jolivanes
01-10-2011, 11:28 PM
What happens if you change this



ComboBox12.RowSource = Range("States").Range("F2", Range("F65536").End(xlUp)).Address


to this



ComboBox12.RowSource = Sheets("States").Range("F2", Sheets("States").Range("F65536").End(xlUp)).Address


Regards
John

simora
01-10-2011, 11:42 PM
jolivanes:

Thanks.

I still cannot access the UserForm if the button is NOT on the States Page.

Aussiebear
01-11-2011, 01:37 AM
Try changing this line from

ComboBox12.RowSource = Range("States").Range("F2", Range("F65536").End(xlUp)).Address to

Me.ComboBox12.RowSource = Range("States").Range("F2", Range("F65536").End(xlUp)).Address

and change the name of the sub to its true name (ie the name of the actual form) and see what happens.

simora
01-11-2011, 10:06 PM
Aussiebear:
Thanks.
I Still cannot access the UserForm from a page other than the page that has the range for the comboBox source on it. Now I get a Run-time error '1004';
The Name of the form is NewClientForm and the error is highlighted at NewClientForm.Show. Same original problem but different error message/number.

simora
01-12-2011, 12:11 AM
Hi:

I cross posted this question at
http://www.mrexcel.com/forum/showthread.php?t=520658

I've got the original problem solved,with Norie's help, but it created another hickup which I'm working on.

Thanks all