我有一个Excel工作表,其中一个单元格由Web查询填充 . 该单元格的内容以单引号( '
)开头 . 单元格具有文本编号格式 .
当我使用VBA将此单元格的内容分配给另一个单元格时,引用将被删除,但我不希望这种情况发生 .
如何获得单元格的精确副本,即引用未删除?
我用:
Dim lSourceRange as Range
Dim lTargetRange as Range
set lSourceRange = Cells(1,1)
set lTargetRange = Cells(2,2)
lTargetRange.numberformat = '@'
lTargetRange.value2 = lSourceRange.Value2
我也试过了
lTargetRange.value2 = lSourceRange.text
lTargetRange.value2 = lSourceRange.Value
lTargetRange.value = lSourceRange.text
lTargetRange.value = lSourceRange.Value
始终删除初始报价 . ( lSourceRange
的值/ value2 / text是 's-Hertogenbosch
,在调试器中看作 "'s-Hertogenbosch"
)
我知道引用是为了向Excel明确表示我想使用文本,但是 I need the quote to be part of the value (and the display in the sheet) .
1 回答
试试这个
或使用此