cancel
Showing results for 
Search instead for 
Did you mean: 

How to AutFit Column of Excel in BluePrism

MohiniShelke
Level 4
Hi ,

I am creating one sheet in Excel at runtime and writing collection data into Excel.

I need to do some formatting for this.
1.Autofill Columns
2.Add boraders to all.
3.Bold Headers.
4.Add Background colour to header.


Anyone knows the solution for this?


Thanks,
Mohini

------------------------------
Mohini Shelke
RPA Developer
vElement It
------------------------------
1 REPLY 1

RoarNilsen
Level 3
Can use the MS Excel VBO action Run Macro
and use the following macro "ExcelFormatting" as a start. 
Change the cell references A:G and A1:G1 as needed or make them dynamic.
Sub ExcelFormatting()
        
    'Autofit columns
    Columns("A:G").AutoFit
    
    'Format header Bold and background color
    Range("A1:G1").Cells.Font.Bold = True
    Range("A1:G1").Cells.Interior.Color = &HC0FFFF
    
    'To format entire row use: Rows("1").Cells.Font.Bold = True
        
    'Autofilter
    If FilterMode = False Then
        'Turn on AutoFilter
        Range("A1:G1").AutoFilter
    Else
        'Reset AutoFilter
        ActiveWorkSheet.ShowAllData
        Range("A1:G1").AutoFilter
    End If
    
  'Borders
   Range("A1:" & Cells.SpecialCells(xlCellTypeLastCell).Address).Select
   With Selection.Borders(xlEdgeLeft)
       .LineStyle = xlContinuous
   End With
   With Selection.Borders(xlEdgeTop)
       .LineStyle = xlContinuous
   End With
   With Selection.Borders(xlEdgeBottom)
       .LineStyle = xlContinuous
   End With
   With Selection.Borders(xlEdgeRight)
       .LineStyle = xlContinuous
   End With

   Range("A1").Select
    
End Sub​


------------------------------
Roar Nilsen
Manager
Duit AS
Europe/Oslo
------------------------------