Identifier Under Cursor is not Recognized

clynch28

New Member
Joined
Sep 21, 2017
Messages
19
I'm writing a sub to pull data from a text file. When trying to run a different form that calls the sub, I am getting the "identifier under the cursor is not recognized" as the reason why after a 424 Object Error. Not sure what is wrong.

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
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Where have you declared the variable apartment?
 
Upvote 0
So you've created a public type named apartment, something like this perhaps?
Code:
'I've used String as the data type for convenience

Public Type apartment
    Name  As String
    bed  As String
    bath  As String
    Size  As String
    pool  As String
    cable  As String
    pet  As String
    fitness  As String
End Type
 
Upvote 0
Yes, except I have bath, bed, and size as integers, pool, cable, pet, and fitness as boolean, and rent as currency. Could that be the issue?
 
Upvote 0
If you want to use your user defined type you need to declare variables of that type.

For example, you could have this,
Code:
Dim myapartment As apartment
which declares a variable myapartment of type apartment.

Another example, which may be more relevant, is this,
Code:
Dim apartments() As apartment
which declares apartments as an array of type apartment.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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