在另一个工作表的两个单元格的地址中,可以连接一个工作表中两个单元格之间的范围

我有Sheet1中的两个单元格包含sheet2中的两个单元格的地址。 例如在sheet1中,单元格(1,1).value的地址为$ A $ 6,单元格(1,2)的地址为$ A $ 100。 这两个地址是指sheet2中的两个单元格。 现在我想连接从sheet2 $ A $ 6到$ A $ 100之间的范围。
我的代码不起作用:

Sub concatenate() Set wss = Sheets("sheet1").Range("sheet2.Cells(1, 1).Value : sheet2.Cells(1, 2).Value") For Each cel In wss tval = tval & cel.Value Next Sheets("sheet2").Cells(1, 7).Value = tval End Sub 

你的语法不正确,因为你将整个参数作为string传递,而它应该是variables和string。 这应该工作,说所有其余的是好的:

 Set wss = Sheets("sheet1").Range(sheet2.Cells(1, 1).Value & ":" & sheet2.Cells(1, 2).Value) 

说明

这: sheet2.Cells(1,1).Value返回"$A$6"如果执行; 但是,如果像上面那样将它写入string(即"sheet2.Cells(1,1).Value" ),则意味着它完全是"sheet2.Cells(1,1).Value" 。 显然, Range("sheet2.Cells(1,1).Value")不存在。