View Single Post
 
Old 10-03-2015, 10:36 AM
shg shg is offline Windows 7 64bit Office 2010 32bit
Advanced Beginner
 
Join Date: Oct 2015
Posts: 55
shg is on a distinguished road
Default

Code:
   -A- B C D E
1   mon a b c e
2   tue b a f a
3   wed b d a d
4   thu a c b f
5   fri d b c a
6   sat c b c e
Select B1, then run

Code:
Sub BG()
  Dim avInp         As Variant
  Dim i             As Long
  Dim j             As Long
 
  avInp = Range(Selection(1), Selection(1).End(xlToRight).End(xlDown)).Value
  With CreateObject("Scripting.Dictionary")
    .CompareMode = TextCompare
    For i = 1 To UBound(avInp, 1)
      For j = 1 To UBound(avInp, 2)
        .Item(avInp(i, j)) = .Item(avInp(i, j)) + 1
        avInp(i, j) = avInp(i, j) & "-" & .Item(avInp(i, j))
      Next j
    Next i
  End With
  Selection(1).Resize(UBound(avInp, 1), UBound(avInp, 2)).Value = avInp
End Sub
Code:
   -A- -B- -C- -D- -E-
1   mon a-1 b-1 c-1 e-1
2   tue b-2 a-2 f-1 a-3
3   wed b-3 d-1 a-4 d-2
4   thu a-5 c-2 b-4 f-2
5   fri d-3 b-5 c-3 a-6
6   sat c-4 b-6 c-5 e-2
Reply With Quote