1
Answer

Dynamically build a string in the Range function

First Last

First Last

1y
661
1

I have multiple buttons each in its own cell on row 12.

I want to make this a dynamic build of the values in the Range function.

So based on one of the cells that a button is clicked (the button sits in cell C12). I get the 'cell letter'. In this case 'C' is inside the variable 'cellLetter'.

I want to dynamically build the Range with the Range function using that. 

incomeCell.Value = ThisWorkbook.Worksheets("ForIrsIncomeAndExpenses").Range(""" & cellLetter & 12").Value

But I get an error. Application-define or object-defined error

Am I concatentating/building the statement in the 'Range' function correctly?

It should build:

incomeCell.Value = ThisWorkbook.Worksheets("ForIrsIncomeAndExpenses").Range("C12").Value

Answers (1)