1
Sub ConcatColumns()
Do While ActiveCell <> "" 'Loops until the active cell is blank.
'The "&" must have a space on both sides or it will be
'treated as a variable type of long integer.
ActiveCell.Offset(0, 1).FormulaR1C1 = _
ActiveCell.Offset(0, -1) & " , " & ActiveCell.Offset(0, 0)
ActiveCell.Offset(1, 0).Select
Loop
End Sub
以上是我拥有的代码。如何连接单个单元格中的2列,即使一列为空
我想将列A & B连接到列C中,并用逗号间隔。 如果列A/B是空的,列C不应该有逗号,而只是值本身。
所以,你想创建一个类似于Excel公式'= IF东西(A1 =“”,IF(B1 =“”,“”,B1),IF(B1 =“”,A1,A1&“,”&B1))'? – YowE3K
yeap。这就像那样 – eqah12