Sub QC_PostProcessing() Dim MainWorksheet As Worksheet ' Make sure your worksheet name matches! Set MainWorksheet = ActiveWorkbook.Worksheets("Test Set") Dim DataRange As Range Set DataRange = MainWorksheet.UsedRange ' Now that you have the data in DataRange you can process it. ' Formateja la taula Range("A1").Select ActiveSheet.ListObjects.Add(xlSrcRange, ActiveSheet.UsedRange, , xlYes).Name = "Table1" ' Neteja retorns de carro a les Descripcions de les proves For Each cellDesc In Range("Table1[Descripció]") Descr = cellDesc.Value ' Esborrar els retorns de carro inicials Set regEx = CreateObject("VBScript.RegExp") With regEx .IgnoreCase = False .MultiLine = True .Pattern = "^[\n\r]*" .Global = False End With Descr = regEx.Replace(Descr, "") ' Esborrar els retorns de carro finals Set regEx = CreateObject("VBScript.RegExp") With regEx .IgnoreCase = False .MultiLine = True .Pattern = "[\n\r]*$" .Global = True End With Descr = regEx.Replace(Descr, "") cellDesc.Value = Descr Next 'Definir nou estil ActiveWorkbook.TableStyles.Add ("Table Style 1") With ActiveWorkbook.TableStyles("Table Style 1") .ShowAsAvailablePivotTableStyle = False .ShowAsAvailableTableStyle = True End With With ActiveWorkbook.TableStyles("Table Style 1").TableStyleElements( _ xlWholeTable).Borders(xlEdgeTop) .ThemeColor = xlThemeColorLight2 .TintAndShade = -0.249946592608417 .Weight = 2 .LineStyle = 1 End With With ActiveWorkbook.TableStyles("Table Style 1").TableStyleElements( _ xlWholeTable).Borders(xlEdgeBottom) .ThemeColor = xlThemeColorLight2 .TintAndShade = -0.249946592608417 .Weight = 2 .LineStyle = 1 End With With ActiveWorkbook.TableStyles("Table Style 1").TableStyleElements( _ xlWholeTable).Borders(xlEdgeLeft) .ThemeColor = xlThemeColorLight2 .TintAndShade = -0.249946592608417 .Weight = 2 .LineStyle = 1 End With With ActiveWorkbook.TableStyles("Table Style 1").TableStyleElements( _ xlWholeTable).Borders(xlEdgeRight) .ThemeColor = xlThemeColorLight2 .TintAndShade = -0.249946592608417 .Weight = 2 .LineStyle = 1 End With With ActiveWorkbook.TableStyles("Table Style 1").TableStyleElements( _ xlWholeTable).Borders(xlInsideHorizontal) .ThemeColor = xlThemeColorLight2 .TintAndShade = -0.249946592608417 .Weight = 2 .LineStyle = 1 End With With ActiveWorkbook.TableStyles("Table Style 1").TableStyleElements(xlHeaderRow _ ).Font .FontStyle = "Bold" .TintAndShade = 0 .ThemeColor = xlThemeColorDark1 End With With ActiveWorkbook.TableStyles("Table Style 1").TableStyleElements(xlHeaderRow _ ).Interior .ThemeColor = xlThemeColorLight2 .TintAndShade = -0.249946592608417 End With ' Estableix nou estil a la taula ActiveSheet.ListObjects("Table1").TableStyle = "Table Style 1" ' Ajusta mida de files i columnes Cells.Select Cells.EntireColumn.AutoFit Columns("E:E").Select Selection.ColumnWidth = 50 Cells.EntireRow.AutoFit Cells.Select Selection.VerticalAlignment = xlTop ActiveWindow.DisplayGridlines = False End Sub