Reputation: 111
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.
Upvotes: 10
Views: 91119
Reputation: 3032
Since DampType
is a string variable, it doesn't need quotation marks -
Damp_DL_Height = ThisWorkbook.Sheets(DampType).Cells(3, 3).Value
Upvotes: 11