これは間違いなく初心者の質問ですが、本当に私を非常に不満にさせます。値を1つの変数に代入した後に値が失われてしまうのはどうしてもわかりません。奇妙なことに、cell_locationの表示には問題はありませんが、cell_locaton1はメッセージボックス内でnullになります。不思議なことに文字列の値が失われました
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にタイプミスがあります –