Našao sam na netu jedan dobar komad koda. Treba mi pomoć da ga očistim od "smeća" i malo stesam.
Evo ga:
Sub InsertRow()
If Range("A1").MergeCells Then
MsgBox "Already done"
Exit Sub
End If
Dim LastRow As Integer, Cnt As Integer, i As Integer
Dim StrRw As String
LastRow = Cells(Rows.Count, "K").End(xlUp).Row
StrRw = Right$(Range("K" & LastRow), 1)
For i = LastRow To 1 Step -1
If Right$(Range("K" & i), 1) <> StrRw Then
Range("A" & i + 1).EntireRow.Insert (xlShiftDown)
Range("A" & i + 1, "K" & i + 1).Merge
Range("A" & i + 1).HorizontalAlignment = xlHAlignCenter
Range("A" & i + 1) = Title(StrRw)
StrRw = Right$(Range("K" & i), 1)
Cnt = 0
Else
'Shading
If Cnt Mod 2 = 0 Then
Range("A" & i, "K" & i).Interior.Color = RGB(192, 192, 192)
End If
Cnt = Cnt + 1
End If
Next
'fill the first row
Range("K" & i + 1).EntireRow.Insert (xlShiftDown)
Range("A" & i + 1, "k" & i + 1).Merge
Range("A" & i + 1).HorizontalAlignment = xlHAlignCenter
Range("A" & i + 1) = Title(StrRw)
End Sub
Mislim da bi ovo boldano trebalo biti ok. Help anyone?