First Last

First Last

  • NA
  • 648
  • 73.3k

Dynamically build a string in the Range function

Apr 13 2023 6:04 PM

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)