VBA 查找列中的最后 5 行并将文本连接到单元格 I2 中,以“,”分隔
VBA to find the last 5 rows in a column and concatenate the text into cell I2, seperated by ","
大家好我正在尝试编写一个代码来查找列 "G" 中的最后一行,然后将最后 5 行用“,”分隔到单元格 "I2" 中。
我知道如何连接 5 个特定的单元格,并找到最后一行等,但我不知道如何将它们连接在一起。
任何帮助或指点将不胜感激。
提前致谢。
第一个Join Function will concatenate a delimited string but the range of rows needs to be flipped with TRANSPOSE
Dim ws7 As Worksheet
Set ws7 = Worksheets("sheet7")
With ws7
With .Cells(Rows.Count, 7).End(xlUp)
With .Resize(5, 1).Offset(-4, 0)
ws7.Cells(2, 9) = _
Join(Application.Transpose(.Cells.Value2), Chr(44))
End With
End With
End With
大家好我正在尝试编写一个代码来查找列 "G" 中的最后一行,然后将最后 5 行用“,”分隔到单元格 "I2" 中。
我知道如何连接 5 个特定的单元格,并找到最后一行等,但我不知道如何将它们连接在一起。
任何帮助或指点将不胜感激。
提前致谢。
第一个Join Function will concatenate a delimited string but the range of rows needs to be flipped with TRANSPOSE
Dim ws7 As Worksheet
Set ws7 = Worksheets("sheet7")
With ws7
With .Cells(Rows.Count, 7).End(xlUp)
With .Resize(5, 1).Offset(-4, 0)
ws7.Cells(2, 9) = _
Join(Application.Transpose(.Cells.Value2), Chr(44))
End With
End With
End With