I'm trying to do what I think is something simple and looks right. What I'm trying to do is pull a value from a cell on a worksheet that is in the current workbook. However, every time I run the code I get the following error: Run-time error'g': Subscript out of range. Below is the listed code that I'm using.
Damp_DL_Height = ThisWorkbook.Sheets("DampType").Cells(3, 3).Value
I've got the variable defined as Double. DampType is equal to the name of the sheet that I'm trying to pull the cell data from. Should I be using some other type of command to get the value?
Any help is appreciated.
To reference a cell or range of cells in another worksheet in the same workbook, put the worksheet name followed by an exclamation mark (!) before the cell address. For example, to refer to cell A1 in Sheet2, you type Sheet2!
Since DampType
is a string variable, it doesn't need quotation marks -
Damp_DL_Height = ThisWorkbook.Sheets(DampType).Cells(3, 3).Value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With