我厌倦了写一个宏,以便B列中的每个单元格在单元格中的整个字符串周围得到quote
个标记
我收到错误Sub or Function not defined
并突出显示CHAR(34)
由于
编辑:现在可以使用
Sub AddQuotesToCells()
Dim rng As Range, cell As Range
Dim LastRow As Long
With Sheets("sheet1")
LastRow = .Range("A" & .Rows.Count).End(xlUp).Row
Set rng = .Range("B2:B" & LastRow)
For Each cell In rng
cell.Value = Chr(34) & cell & Chr(34)
Next
End With
End Sub
答案 0 :(得分:3)
它不是CHAR()
Chr()
。另外,您是否忘记.
range
行前Set rng = range...
了?
对于公式问题:
更改
rng.Formula = "=" & CHAR(34) & "B2" & CHAR(34) & ""
通过
rng.Formula = "=""""""" & Chr(34) & "&" & "B2" & "&" & Chr(34) & """"""""