What is the syntax for using a variable to reference a specific cell

I need to be able to specify a starting point in my spreadsheet.
Therefore, I am using an Inputbox to ask for the starting row and asigning the input to the variable “activerow”. The column will always be A. My target is the Read Cell Value activity.

I have tried [activerow]A and too many other variations to recall.

Any help would be appreciated.

Hey @dhtguru
If you’re using the Read Cell Value activity and want to build the cell reference dynamically with a variable, you can do it like this:

"A" & activerow.ToString

So if activerow = 1, the result will be “A1” - which is a valid cell reference.
You can increase this value in For Each loop.
Just make sure this variable is of type Int32.

Depends exactly which activities you’re using. With the old-style Workbook activities it’s just a string ie “A1” “B2” etc. But with the newer Excel activities it’s an expression. Show us your code so we know what you’re trying to do.

By the way, why not just read the sheet without headers, starting from A1, and use code to figure out where everything actually starts?

Thank you Piotr

I must be doing something wrong. I have the variable set to Int32, entering “A” & activerow.ToString in he Expression Editor of Read Cell Value; however,

I am getting the error message Argument ‘Cell’: BC30512: Option Strict On disallows implicit conversions from string to ‘IRefCellRef’. The selected value is incompatible with the property type.

Please advise.

Hey @dhtguru
To fix it, you can use the Excel.Sheet("SheetName").Cell("A" & activerow.ToString) expression instead.

That did it!
Thank you Piotr!

@dhtguru
Awesome, glad it worked! :slight_smile:
If my answer helped solve your issue, feel free to mark my post as the solution so others can benefit too. Thanks! :wink:

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