DeanRobinson
New Member
- Joined
- Sep 1, 2011
- Messages
- 35
Hi all i want to extend the below code to insert blank rows after the value of a cell changes so once it runs the below code which pulls data from another file and then sorts the data, i now want it to go one step further and everytime the value in Column G changes it will add a blank row,
The sheet assigns the technicain to his team manager and then sorts first by the team managers name, second by the tech id and third by the appointment time slot. Just to make to easier to read what id like is once the tech id changes it would insert an entire blank row. i hope this makes sense.
The sheet assigns the technicain to his team manager and then sorts first by the team managers name, second by the tech id and third by the appointment time slot. Just to make to easier to read what id like is once the tech id changes it would insert an entire blank row. i hope this makes sense.
Rich (BB code):
ISub TeamManager()
With Application: .ScreenUpdating = False: [b:b].EntireColumn.Insert: [b1] = "Team Manager"
With Range([b2], Cells(ActiveSheet.UsedRange.Rows.Count, 2))
.FormulaR1C1 = "=IF(ISERROR(VLOOKUP(RC[5],'C:\Users\DeanRobinson\Documents\[TECHTM.xls]Sheet1'!C1:C2,2,0)),"""",VLOOKUP(RC[5],'C:\Users\DeanRobinson\Documents\[TECHTM.xls]Sheet1'!C1:C2,2,0))"
.Copy: .PasteSpecial Paste:=xlPasteValues
End With: Application.CutCopyMode = False: .ScreenUpdating = True: End With:
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("B:B") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("G:G") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("J:J") _
, SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _
"FIRST VISIT,8am-1pm,10am-2pm,12-6pm,1pm-6pm", DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A:CI")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.Apply
End With
End Sub
Last edited: