VBA Code to Invoke Code with Datatable

I was wondering if I can use the Invoke Code to change the format of the cells in my Excel file. (Fonts, Bold, Border, etc)

Sub formatCell()

Dim ws As Worksheet: Set ws = ThisWorkbook.ActiveSheet
Dim lastRow As Long

lastRow = Cells(Rows.Count, 4).End(xlUp).Row

With ws.Range(ws.Cells(lastRow, 4), ws.Cells(lastRow, 10))
.Font.Bold = True
.Borders.LineStyle = xlContinuous
End With

End Sub

This is the code that I want to use. Is there any way to incorporate that in there?
Thank you.

Hi @phiking,

You can keep the macro within the Excel file and invoke it through the Invoke VBA activity https://docs.uipath.com/activities/docs/invoke-vba activity https://docs.uipath.com/activities/docs/invoke-vba

Hope this helps
Best regards,
Marius

Hello @Marius_Puscasu
Is there any way I can do it without the Excel Application Scope?
It would be better for my code.