Read range from cell with column alphabets

Hi All,

I am trying to use UiPath to copy and paste for a defined range.
I have the start and end range defined but the column changes everytime.

Is there a way for UiPath to read cell and pick up the column alphabets? The rows are fixed.
For example, I have defined cell B19 as my start column and C19 as the end column as generic values. (these columns will change).
I would like UiPath to read range from startcolumn row 6 to endcolumn row 10.
Does the below work or will I have to add .ToString to it?

(StartColumn)+“6”+":(EndColumn)"+“10”

image

Thanks!

1 Like

Hi

check this thread for details on datatable and getting the Column alphabets

Hope this would help you resolve this issue

Cheers @victorialim

Thanks for the reply @Palaniyappan .

I have tried defining my Start and End Column and keyed in the below in read range.
(StartColumn)+“6”+":(EndColumn)"+“10”
However, I’m getting the below RemoteWrap error saying it cannot read the below:
JK6:(EndColumn)10
Looks like it picked up the cell correctly except for the (EndColumn) is not reflecting as JJ.
Do I have to add any To.String behind?

Thanks!

because it read endColumn as a string, since endcolumn was written inside double quotes

should be like this @victorialim

(StartColumn)+"6:"+(EndColumn)+"10"

Thanks @jack.chan , it works for read and write range.
However, when I’m using it for autofill range to copy and paste formula within that range, I’m seeing the below error. Does it not work for autofill range?
Thanks!

image

@victorialim

what is the range you want to fill? can you show a screenshot of your excel and tell us where you want to autofill?

Please ignore the errors as these are bloomberg formula and im currently not linked to the terminal.

I have JF defined as FormulaColumn and JL as PasteColumn.
I am trying to copy and paste the formulas from JF6:JF10 to JL6:JL10.

As the Formula and Paste Column will change, I need to define them as variables instead of typing JF and JL straight into the auto fill range.

Thanks.

1 Like

autofill range doesnt work for your requirement , it works if you want to drag e.g. cell B1 to B5 i.e. they have to be connected

you can try this instead

  1. copy below code to text file e.g. “VBA.txt”
  2. in excel application scope, call invoke vba activity, pass in vba text path and the function name = CopyAndPasteRange
    image
  3. under entryMethodParameters, pass in this:

{FormulaColumn+"6:"+FormulaColumn+"10", PasteColumn+"6:"+PasteColumn+"10", "Sheet1"}

where Sheet1 = your sheet name

Function CopyAndPasteRange(copyRange As String, pasteRange As String, sheetName As String)

    ActiveWorkbook.Sheets(sheetName).Activate
    Range(copyRange).Select
    Selection.Copy
    Range(pasteRange).Select
    ActiveSheet.Paste
    
    ActiveWorkbook.Save
End Function