Takes unformatted csv, formats it into a table, then adds lines between sections where the value in A or B doesn’t match the line before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub csv_config_audit_2() | |
' | |
' csv_config_audit_2 Macro | |
' | |
' | |
Range("A1").CurrentRegion.Select | |
ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1").CurrentRegion, , xlYes).Name = _ | |
"Table1" | |
Range("Table1[#All]").Select | |
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleDark8" | |
Columns("D:D").EntireColumn.AutoFit | |
Columns("A:A").EntireColumn.AutoFit | |
Columns("B:B").EntireColumn.AutoFit | |
Columns("C:C").EntireColumn.AutoFit | |
Range("Table1[[#Headers],[template_name]]").Select | |
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleLight13" | |
Range("Table1[#All]").Select | |
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$A1<>$A2" | |
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority | |
With Selection.FormatConditions(1).Borders(xlBottom) | |
.LineStyle = xlContinuous | |
.TintAndShade = 0 | |
.Weight = xlThin | |
End With | |
Selection.FormatConditions(1).StopIfTrue = False | |
Range("Table1").Select | |
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$B1<>$B2" | |
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority | |
With Selection.FormatConditions(1).Borders(xlBottom) | |
.LineStyle = xlContinuous | |
.TintAndShade = 0 | |
.Weight = xlThin | |
End With | |
Selection.FormatConditions(1).StopIfTrue = False | |
Range("A1").Select | |
End Sub |