View Single Post
 
Old 08-30-2017, 04:45 AM
kgoosen kgoosen is offline Windows 10 Office 2016
Novice
 
Join Date: Aug 2017
Posts: 1
kgoosen is on a distinguished road
Default Insert rows when column A data changes then shade and autosum blanks in columns E to I

I currently have a macro which inserts a row whenever the data in column A changes. What I want to add is that it also shades and autosums columns E throught to I as well.

Could somebody please help me with this?

Here is the code that I am using to insert a row when the data in column A changes

Sub InsRowsWhenCellDataChangesColA()
Dim r As Long, mcol As String, i As Long

' find last used cell in Column A
r = Cells(Rows.Count, "A").End(xlUp).Row

' get value of last used cell in column A
mcol = Cells(r, 1).Value

' insert rows by looping from bottom
For i = r To 2 Step -1
If Cells(i, 1).Value <> mcol Then
mcol = Cells(i, 1).Value
Rows(i + 1).Insert
End If
Next i

End Sub
Reply With Quote