I have a workbook containing properties, each with a respective property ID. The code below aims to find the row corresponding to the ID chosen from a list in a comboBox and then fill the remainder of the fields in the form with the data in it's row.
Private Sub propertyCodeCombo_change()
Set wks = Application.Workbooks("Book1.xlsm").Worksheets("Property")
Dim propertyCell As Range
Set propertyCell = wks.Range("A2")
Do Until propertyCell.Value = propertyCodeCombo.Value
Set propertyCell = propertyCell.Offset(1, 0) <--Error Occurs here
Loop
addressText = propertyCell.Offset(0, 1).Value
suburbText = propertyCell.Offset(0, 2).Value
propertyTypeCombo = propertyCell.Offset(0, 3).Value
bedroomsText = propertyCell.Offset(0, 4).Value
bathroomsText = propertyCell.Offset(0, 5).Value
weeklyRentalFeeText = propertyCell.Offset(0, 6).Value
statusCombo = propertyCell.Offset(0, 7).Value
commisionText = propertyCell.Offset(0, 8).Value
ownerCodeCombo = propertyCell.Offset(0, 9).Value
End Sub
I find strange as I have almost identical code as seen below that does not cause an error and functions perfectly.
Set wks = Application.Workbooks("Book1.xlsm").Worksheets("Property")
Dim propertyCell As Range
Set propertyCell = wks.Range("A2")
Do Until IsEmpty(propertyCell)
Set propertyCell = propertyCell.Offset(1, 0)
Loop
propertyCell.entireColumn.Find(propertyCodeCombo.Value,,xlWhole)? If the findis nothingthen just catch the error.