Vba 在公式1c1中连接

Vba 在公式1c1中连接,vba,excel,Vba,Excel,我试图提取字符串的前8个字符,同时使用.FormulaR1C1将“/”插入到第8个字符的位置。但是,我不认为我写的串联函数是正确的 我需要 MK442LLA-PB-3RC 成为 MK442LL/A 我使用的R1C1串联公式如下所示: With Range("D2") .FormulaR1C1 = "=CONCATENATE(LEFT(RC[-1], 7)""/""MID(RC[-1], 8, 1))" .AutoFill Destination:=Range("D2:D"

我试图提取字符串的前8个字符,同时使用.FormulaR1C1将“/”插入到第8个字符的位置。但是,我不认为我写的串联函数是正确的

我需要

MK442LLA-PB-3RC 
成为

MK442LL/A
我使用的R1C1串联公式如下所示:

With Range("D2")
    .FormulaR1C1 = "=CONCATENATE(LEFT(RC[-1], 7)""/""MID(RC[-1], 8, 1))"
    .AutoFill Destination:=Range("D2:D" & lastRow)
End With    

注意:我使用Mid()而不是Right(),因为初始数字的长度不同。

使用Mid()而不是“.FormulaR1C1”怎么样?相应地抵消

Sub concatFirstEight()

'last row
lastRow = range("D1048576").end(xlup).row

'set your range
Set concatRange = Range("D2:D" & lastRow)

'loop through range and add a "/" between the 7th and 8th character
For Each c In concatRange
    c.Value = Mid(c, 1, 7) & "/" & Mid(c, 8, 1)
Next

End Sub

串联中的参数之间缺少逗号。