Write cell in Excel and merge 2 cells to write a single text

Hi all,

I’m using Write cell activity in UiPath where i want to merge 2 cells and write in it.

Eg.

I want to write “Hi” in cells A1 and A2.
I want to also bold it and add colour to the cell.

Is it possible?

Thanks in advance!

Hi @Ray_Sha1
check out workflows
MergeCells.zip (24.9 KB)
Excel_AddRow_MergeAndColor.zip (12.6 KB)

Hi @Ray_Sha1 ,

Could you check the below post, it should be similar to your requirement :

Hi,

Im looking for something as simple as this above-mentioned image.

Thanks

Hello @Ray_Sha1
You can use Format cells activity to add color to the cells and for merging you can use vb script.

1 Like

Is there a vb script for this?
Format cells works but I’ll looking for a script.

Thanks in advance

Ddi you checked the link which I shared?

@Ray_Sha1

  1. paste below code in file e.g. vba.txt
  2. in excel application scope, call invoke vba activity
    set codeFilePath = "vba.txt
    "EntryMethodName" = “FormatAndMerge”
    EntryMethodParameters = {“SheetName”, “textToWrite”, “cellsToMerge”}
    e.g. {"Sheet1", "hi", "A1:A2"}
Function FormatAndMerge(sheetName As String, textToWrite As String, cellRange As String)
'
    ActiveWorkbook.Sheets(sheetName).Activate
    Range(cellRange).Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Selection.Merge
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 65535
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    ActiveCell.FormulaR1C1 = textToWrite
    ActiveWorkbook.Save
End Function
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.