First time in VBA.

Abstracted Problem pseudocode: I have an output sheet with 3 rows (date, code, cash). I input a date in cell A1.

[Date][Date]
[code][code]
[cash][cash]

I want to loop through the date row and find the date that matches A1 input date. If it matches I want to check the cell in the row under it for a "code" match ("code" is 1). If both date and code match, I want a variable, cash, to store the value in the cell on the 3rd row of that matching column. There will always only be 1 match, and 20 columns is sufficient to check.

I am getting an "object required" error on the "Set curCell" line.


Sub GetCash()

Dim theDate As String: theDate = Worksheets("Sheet1").Range("A1").Value

Dim curCell As Range, perCell As Range, cashCell As Range, Counter As Integer, Cash As Integer

 For Counter = 1 To 20

 Set curCell = Worksheets("Sheet1").Cells(5, Counter).Value2
 Set perCell = Worksheets("Sheet1").Cells(6, Counter).Value2
 Set cashCell = Worksheets("Sheet1").Cells(7, Counter).Value2

 If curCell = theDate And perCell = 1 Then Cash = cashCell

 Next Counter

MsgBox Cash

End Sub