How to make a particular row in excel bold

Here I need to make a particular row bold. The index of row is passed as a variable named totRange.
Sub CalcBold()
Selection.Font.Bold = True
End Sub

instead of 17th row, I need to pass variable totRange.

How to write the macro?

1 Like

@rifnanahas use this…RowNo is the variable u need to pass eg) rowNo = 17
Rows(RowNo).Font.Bold = True
Hope this helps

as an alternate option to macro, with UiPath activities it can be done like following:

Select Range activity - here we can pass the range dynamic with a variable
Send Hotkey Activity - indicating to Excel with the selector

Hotkeys for bold:

  • CTRL+2
  • CTRL+B ( in some cases, depends on language / locals)
  • CTRL+SHIFT+F (local command e.g. for German, similar to the shortcut showing when hovering the Bold format Button in the ribbon menu)

Doing it with VBA / Macro:

  • using invoke VBA activity and pass the variable within the EntryMethodParameters
  • using execute Macro Activity and pass the variable within the MacroParameters
1 Like

how to pass variable in invoke vba activity. can you please tell about also

@rifnanahas In the entry paramters of invoke vba activity, give the variable names that you need inside the macro in this format
And in the macro, receive these variables in the same sequence
eg) Sub getmacrovar(variable1 As string, variable2 As string)

This will take your uipath variable sinside macro .Hope this answers your question

I have 2 variables and when I use this:

Sub CalcBold(totRange As String, avgRange As String)
Rows(totRange, avgRange).Select
Selection.Font.Bold = True
End Sub

its not working…

my invoke vba activity will look like this:

@rifnanahas Bold a row using vba.xaml (6.1 KB) macr.txt (224 Bytes)

I have created a workflow,just rename the excel folder location and macro text file location

Hi @rifnanahas

use excel application scope and use select range as D17 and use send hot key as ctrl+b

Ashwin S