我正在尝试将变量分配给单元格值,但由于某种原因我总是得到零。
Sheets(3).Activate
RowNo = 30
ColNo = 2
EU1 = Range(Cells(RowNo, ColNo).Address()).Value
MsgBox EU1
Check the image for cell address and value
我使用Range(Cells(RowNo, ColNo))
的原因是因为我有一个需要循环访问的表来检查日期,如果它等于(或者小于今天)变量EU1将被更新。 / p>
答案 0 :(得分:0)
Const
)。Dim
声明其他变量。Option Explicit
,这样,如果未声明变量(Dim
或Const
...
现在)。Set
语句。Option Explicit
Sub ReturnValue()
Const cSheet As String = "Sheet3"
Const cRow As Long = 30
Const cCol As Long = 2
Dim ws As Worksheet
Dim EU1 As Double
Set ws = ThisWorkbook.Worksheets(cSheet)
EU1 = ws.Cells(cRow, cCol).Value
MsgBox EU1
End Sub