Dim Lst As New List(of String) For each g As SubtotalGroup In CurrentTable.SubtotalGroups For Each s As string In g.Totalon.Split(",") If lst.Contains(s) = False Then lst.Add(s) End If next If lst.Contains(g.Groupon) = False Then lst.Add(g.GroupOn) End If Next For Each c As Col In CurrentTable.Cols c.Visible = lst.Contains(c.Name) Next