Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function GetReceipt(NamesRange As Range, ValuesRange As Range) As String
- Dim I As Integer
- Dim Value As Integer
- Dim Name As String
- Dim FoundCount As Integer
- Dim LastName As String
- FoundCount = 0
- For I = 1 To ValuesRange.Columns.Count
- Value = ValuesRange.Cells(1, I).Value
- Name = NamesRange.Cells(1, I)
- If Value > 0 Then
- ResultString = ResultString & Name & "-" & Value & ","
- LastName = Name
- FoundCount = FoundCount + 1
- End If
- Next I
- If FoundCount = 1 Then
- ResultString = LastName
- ElseIf FoundCount = 0 Then
- ResultString = ""
- Else
- ResultString = Left(ResultString, Len(ResultString) - 1)
- End If
- GetReceipt = ResultString
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement