How to find a Excel cell address dynamically and write content

excel
activities

#1

Hi
I have an excel file wherein I need to look through a row value and a column value. After that I want to write some value in it. For example, in below screen shot, I need to find where “RowValueToBeSearched” and “ColumnValueToBeSearched” are written and then I need to feed my input in their intersecting cell address “H5” in below example.
How to do that?


How to get active cell address from Excel
#2

For example if you want to get row value ex. row(0). tostring and save it in another variable using assign. then H row value as row(7).to string and save it in another variable using assign. Create these to inside for each. so it will read each row first column and 7 th column values.


#3

Can you please be more elaborative and stepwise? I hope you got my question. I don’t need excel cell values. I want excel cell address based on intersecting cell values.


#4

cell address starts with 0. for column A cell address is 0.

column B=1
c=2
d=3
+++++
use row (3).tostring for d column. assign the value to column and write it back to datatable then use write cell option.

Specify your req.


#5

Hi
My Requirement is simple. Stepwise I would like to do something like below:

  1. Search for “ColumnValueToBeSearched” and store its column index (or name) in a variable (say “column”)
  2. Search for “RowValueToBeSearched” and store its row index (or name) in a variable (say “row”)
  3. Use WriteCell activity using “row” and “column” variables.

#6

Hi,

there’s probably a cleaner way to achieve this, but one working way is to loop through the datatable and use counters. When desired value is found save the counter as index value.

int colidx;
int rowidx;
int rowCounter = 0;
foreach row in myDT.Rows
{
int colCounter = 0;
foreach item in row.ItemArray
{
if (item.ToString = “column value”)
{
colidx = colCounter;
}
colCounter = colCounter + 1;
if (item.ToString = “row value”)
{
rowidx = rowCounter;
}
}
rowCounter = rowCounter + 1;
}

This will return rowidx as an int where the desired row value was found and colidx as an int where the desired col value was found.

Br,
Topi


#7

Thanks @Topi
I am trying on that line only now.