When I run this module I get an Object Required error. I'm a novice with VBA and I don't see what's wrong with the code.
Sub CountOccurances()
Dim Total As Integer
Dim Column As Integer
Dim Row As Integer
Total = 0
For Column = 2 To 51
If Worksheets("Sheet1").[13,Column].Value = 1 Then
For Row = 12 To 16
If Worksheets("Sheet1").[Row, Column].Value = 2 Then Worksheets("Sheet1").[20,Row 8].Value = Total 1
Next Row
End If
Next Column
End Sub
I have tried a few modifications, but without success.
CodePudding user response:
Use the Cells property, as in:
Worksheets("Sheet1").Cells(13, Column).Value = 1
instead of the shortcut notation; the latter is good for a range defined by a starting and ending cell reference separated by a colon (like [A1:C5])