HI All,
Could someone please help me comment out the below macro on what each or a line does.
This is used to auto assign task but I am trying to tweak few things but dont know where exactly i need to change things up. If someone can help me comment the line for example 'This splits colums or 'this assigns name would be nice.
Could someone please help me comment out the below macro on what each or a line does.
This is used to auto assign task but I am trying to tweak few things but dont know where exactly i need to change things up. If someone can help me comment the line for example 'This splits colums or 'this assigns name would be nice.
Code:
[COLOR=#333333]Sub test()[/COLOR][COLOR=#3E3E3E][COLOR=#333333][INDENT]<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;"> Dim a, i As Long, dic As Object, dicAgnt As Object
Dim r As Range, LastR As Range, flg As Boolean
Set dic = CreateObject("Scripting.Dictionary")
Set dicAgnt = CreateObject("Scripting.Dictionary")
dic.CompareMode = 1
a = Sheets("tasklist").Cells(1).CurrentRegion.Value
For i = 2 To UBound(a, 1)
If a(i, 3) = "Yes" Then
If Not dicAgnt.exists(a(i, 2)) Then
ReDim w(1 To 1)
Else
w = dicAgnt(a(i, 2))(0)
ReDim Preserve w(1 To UBound(w) + 1)
End If
w(UBound(w)) = a(i, 1)
dicAgnt(a(i, 2)) = Array(w, 0)
End If
Next
Sheets("master").Cells.Clear
With Sheets("raw data").Cells(1).CurrentRegion
.Parent.AutoFilterMode = False
a = .Columns("s").Value
For i = 2 To UBound(a, 1)
If Not dic.exists(a(i, 1)) Then
dic(a(i, 1)) = Empty
If Not Evaluate("isref('" & a(i, 1) & "'!a1)") Then
Sheets.Add(, Sheets(Sheets.Count)).Name = a(i, 19)
End If
Sheets(a(i, 1)).Cells.Clear
.AutoFilter 19, a(i, 1)
Union(.Columns("A:B"), .Columns("E"), .Columns("H"), _
.Columns("J"), .Columns("N:O"), .Columns("R:V")).Copy
With Sheets(a(i, 1)).Cells(1)
.PasteSpecial xlPasteFormats
.PasteSpecial xlPasteColumnWidths
.PasteSpecial xlPasteValues
With .CurrentRegion.Columns("i")
For Each r In .Cells
If dicAgnt.exists(r.Value) Then
w = dicAgnt(r.Value)
w(1) = w(1) + 1
If w(1) > UBound(w(0)) Then w(1) = 1
r(, 5).Value = w(0)(w(1))
dicAgnt(r.Value) = w
End If
Next
End With
.CurrentRegion.Offset(IIf(flg, 1, 0)).Copy
End With
With Sheets("master")
If flg Then
Set LastR = .Range("a" & Rows.Count).End(xlUp)(2)
Else
Set LastR = .Cells(1)
End If
LastR.PasteSpecial xlPasteFormats
LastR.PasteSpecial xlPasteColumnWidths
LastR.PasteSpecial xlPasteValues
flg = True
End With
.AutoFilter
End If
Next
Application.Goto .Cells(1)
End With
End Sub</code>
[/INDENT]
[/COLOR]
[/COLOR]
[COLOR=#3E3E3E][B][RIGHT][/RIGHT]
[/B][/COLOR]