我已編碼下面的宏,它是工作時,我將值保存到立即窗口,但不知道如何填充值,用「,」分隔到一個單元格。基本上,我在一列中尋找「有效」,如果找到了,就去4個單元格左邊,並從那裏獲取信息... 你能幫忙嗎?刪除重複,連接,從頂部
Dim Active() As Variant
Dim i
ReDim Active(Range("G9:G24").Cells.Count)
For Each Zelle In Range("G9:G24")
If InStr(1, Zelle, "Active") <> 0 Then
Active(i) = Zelle.Offset(0, -4)
End If
i = i + 1
Next Zelle
For i = LBound(Active) To UBound(Active)
If Trim(Active(i)) <> "" Then
Debug.Print Active(i)
End If
Next i
End Sub
你可能要考慮的加入功能。 –
@RichHolton Join函數是很自然的,但是'Trim(Active(i))<>「」'表明它可能有空的字段,在連接之後必須修復它們。 –
@JohnColeman好點。 –