从工作表上的单元格获取价值 [英] Get Value from a cell on a worksheet
问题描述
我正在尝试做我认为简单且看起来正确的事情.我想做的是从当前工作簿中工作表上的一个单元格中提取一个值.但是,每次我运行代码时,都会出现以下错误:运行时错误'g':下标超出范围.下面是我正在使用的列出的代码.
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
我已将变量定义为Double. DampType等于我要从中提取单元格数据的工作表的名称.我应该使用其他类型的命令来获取值吗?
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?
感谢您的帮助.
推荐答案
由于DampType
是字符串变量,因此不需要引号-
Since DampType
is a string variable, it doesn't need quotation marks -
Damp_DL_Height = ThisWorkbook.Sheets(DampType).Cells(3, 3).Value
这篇关于从工作表上的单元格获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!