Issue Showing a Form

clynch28

New Member
Joined
Sep 21, 2017
Messages
19
I created a user form and changed the name of it to SearchForm. When I wrote a sub to call on the form, I keep getting a runtime error 424 saying that there is an object required. Not sure why it isn't working now when it was working earlier. Any help would be much appreciated. Heres what I wrote:

Sub main()

Call clearOutput
Call loadData

SearchForm.Show

End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Is there any code in the userforms Activate/Initialize events?

If there is that could be where the error is.

To check that open the form in design view and press F5 (to open the form) or F8 (to open the form in debug mode).
 
Upvote 0
Here's the code for initializing the form. I double checked everything and I am not sure what could be wrong with it.

Private Sub UserForm_Initialize()


bedComboBox.Style = fmStyleDropDownList
bathComboBox.Style = fmStyleDropDownList
sizeComboBox.Style = fmStyleDropDownList


With bedComboBox
.AddItem "1"
.AddItem "2"
.AddItem "3"
.AddItem "4"
End With


With bathComboBox
.AddItem "1"
.AddItem "2"
.AddItem "3"
End With


With sizeComboBox
.AddItem "less than 500 sf"
.AddItem "501-1000 sf"
.AddItem "1001-1500 sf"
.AddItem "1501-2000 sf"
.AddItem "more than 2000 sf"
End With


With Page3
OptionButton1.Value = True
End With


Page1.Select


End Sub



 
Upvote 0
When you step through that code with F8 what happens?
 
Upvote 0
On which line of code do you get the error when you step through with F8?
 
Upvote 0
It happens in the sub located below at the apartment.name = arrayForOneLine(0).



Sub loadData()


Dim txtFile As String
Dim dataLine As String
Dim row As Integer, column As Integer
Dim arrayForOneLine() As String




txtFile = ThisWorkbook.Path & "/data.txt"
Open txtFile For Input As #1




Do Until EOF(1)
Line Input #1 , dataLine
arrayForOneLine = Split(dataLine, vbTab)
row = row + 1
ReDim apartmentArray(row)

apartment.name = arrayForOneLine(0)
apartment.bed = arrayForOneLine(1)
apartment.bath = arrayForOneLine(2)
apartment.size = arrayForOneLine(3)
apartment.pool = arrayForOneLine(4)
apartment.cable = arrayForOneLine(5)
apartment.pet = arrayForOneLine(6)
apartment.fitness = arrayForOneLine(7)
apartment.size = arrayForOneLine(8)


Loop
Close #1


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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