Looking for some help or advice. Trying to create a Macro that will concatenate 4 columns A-D with a ~ separator in Column F. It needs to start in E2 and continue till empty cell in column D. I have tried the below so far but fails to continue past E3.
Sub ConCat()
'
' ConCat Macro
'
'
Dim oWS As Worksheet, lLastRow As Long, r As Long
Set oWS = ActiveSheet
lLastRow = oWS.Cells.SpecialCells(xlLastCell).Row
For r = 1 To lLastRow
' Combine A to D
If Len(oWS.Cells(r, 4)) > 0 And Len(oWS.Cells(r, 5)) > 0 Then
oWS.Cells(r, 5).Value = oWS.Cells(r, 1).Value & "~" & oWS.Cells(r, 2).Value & "~" & oWS.Cells(r, 3).Value & "~" & oWS.Cells(r, 4).Value
End If
Next
End Sub
Sub ConCat()
'
' ConCat Macro
'
'
Dim oWS As Worksheet, lLastRow As Long, r As Long
Set oWS = ActiveSheet
lLastRow = oWS.Cells.SpecialCells(xlLastCell).Row
For r = 1 To lLastRow
' Combine A to D
If Len(oWS.Cells(r, 4)) > 0 And Len(oWS.Cells(r, 5)) > 0 Then
oWS.Cells(r, 5).Value = oWS.Cells(r, 1).Value & "~" & oWS.Cells(r, 2).Value & "~" & oWS.Cells(r, 3).Value & "~" & oWS.Cells(r, 4).Value
End If
Next
End Sub