这绝对是一个新手问题,但真的让我非常沮丧。我无法弄清楚为什么我会在将值赋给一个变量后丢失了值。奇怪的是,显示cell_location没有问题,但cell_locaton1在消息框中变为空。奇怪的丢失字符串值
Sub COPYCELL()
Dim bottomCell As Range
Dim offsetCell As Range
Dim cell_location As String
Dim cell_location1 As String
Dim SC As String
With ActiveSheet
Set bottomCell = .Cells.Find(what:="XXX")
Set offsetCell = .Cells.Find(what:="YYY")
cell_location = "A" & bottomCell.Row
cell_locaton1 = "A" & offsetCell.Row
SC = cell_location & ":" & cell_location1
MsgBox SC
End With
End Sub
这个问题的最佳答案是两个字:Option Explicit。试试:) –
cell_locaton1 =“A”中有一个错字&offsetCell.Row –