I want to create an enquiry sheet for users to check their own data. When user inputting some information which fits to the data list, the rest of their data will show up.
I've type the code as below and I guess probably it's lacking something because the error code "Run-time error '424': Object required" keeps popping up. And I have no idea what's lacking. Here's the code:
Sub EnquiryChecking()
Dim i As Integer
If (Sheet1.Cells(3, 3) = DataList.Cells(i, 1)) And (Sheet1.Cells(4, 3) = DataList.Cells(i, 4)) And (Sheet1.Cells(5, 3) = DataList.Cells(i, 5)) Then
Sheet1.Cells(7, 3) = DataList.Cells(i, 2)
Sheet1.Cells(8, 3) = DataList.Cells(i, 3)
Sheet1.Cells(9, 3) = DataList.Cells(i, 6)
Sheet1.Cells(10, 3) = DataList.Cells(i, 7)
Sheet1.Cells(11, 3) = DataList.Cells(i, 8)
Sheet1.Cells(12, 3) = DataList.Cells(i, 9)
Else
Sheet1.Cells(14, 2) = "Error Input"
End If
End Sub
Many thanks!
A further update:
I added a for
loop for i
and now the code can run. But now the Sheet1.Cell
doesn't show the DataList.Cell
data (even the input is not correct, it doesn't show "Error Input". What happened? Also, what should I add if I want to show the data instantly in the cell?
Here's the code:
Sub EnquiryChecking()
Dim i As Integer
For i = 1 To i
If (ActiveWorkbook.Sheets("Sheet1").Cells(3, 3) = ActiveWorkbook.Sheets("DataList").Cells(i, 1)) And (ActiveWorkbook.Sheets("Sheet1").Cells(4, 3) = ActiveWorkbook.Sheets("DataList").Cells(i, 4)) And (ActiveWorkbook.Sheets("Sheet1").Cells(5, 3) = ActiveWorkbook.Sheets("DataList").Cells(i, 5)) Then
Worksheets("Sheet1").Cells(7, 3) = Worksheets("DataList").Cells(i, 2)
Worksheets("Sheet1").Cells(8, 3) = Worksheets("DataList").Cells(i, 3)
Worksheets("Sheet1").Cells(9, 3) = Worksheets("DataList").Cells(i, 6)
Worksheets("Sheet1").Cells(10, 3) = Worksheets("DataList").Cells(i, 7)
Worksheets("Sheet1").Cells(11, 3) = Worksheets("DataList").Cells(i, 8)
Worksheets("Sheet1").Cells(12, 3) = Worksheets("DataList").Cells(i, 9)
Exit For
Else
Sheet1.Cells(14, 2) = "Error Input"
End If
Next i
End Sub