Forum Discussion
Jarden
May 19, 2022Copper Contributor
Counting time increments based on the number of times a text appears
Hi there. I work at a company that meets with clients. We use their initials on the schedule. Goal: Count the number of hours a client is scheduled. Progress: I am able to count hours fairly eff...
OliverScheurich
May 19, 2022Gold Contributor
Sub customer()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim z As Double
For i = 3 To 6
For k = 7 To 9
For j = 2 To 4
If InStr(1, Cells(i, j), Cells(2, k), vbTextCompare) Then
Select Case Len(Cells(i, j)) - Len(Replace(Cells(i, j), "/", ""))
Case Is = 0
z = z + 1
Case Is = 1
z = z + 0.5
Case Is = 2
z = z + 0.33
End Select
Else
End If
Next j
Cells(i, k).Value = z
z = 0
Next k
Next i
End SubMaybe with these lines of code. You can click the button in cell L2 in the attached file to start the macro.