The VBA code below matches numbers (indicating 0 or 1) between column A and column B and lists them in single column D. How would I list them in multiple columns (preferably 4) instead?
Public Sub CountA_FillC()
Dim RowA As Long, RowB As Long
Dim UsedRange As Range: Set UsedRange = ActiveSheet.UsedRange
For RowB = 1 To UsedRange.Rows.Count
Dim Count As Long: Count = 0
For RowA = 1 To UsedRange.Rows.Count
If UsedRange(RowA, "A").Value = UsedRange(RowB, "B").Value Then
Count = Count + 1
End If
Next RowA
UsedRange(RowB, "D").Value = Count
Next RowB
End Sub
Public Sub CountA_FillC()
Dim RowA As Long, RowB As Long
Dim UsedRange As Range: Set UsedRange = ActiveSheet.UsedRange
For RowB = 1 To UsedRange.Rows.Count
Dim Count As Long: Count = 0
For RowA = 1 To UsedRange.Rows.Count
If UsedRange(RowA, "A").Value = UsedRange(RowB, "B").Value Then
Count = Count + 1
End If
Next RowA
UsedRange(RowB, "D").Value = Count
Next RowB
End Sub