I'm trying to write a macro to concatenate five columns of information (Columns A - F) into Column G.
Everything in Column A starts with either ABC, DEF, or GHI, and I'd like the macro to skip Column E for rows where Column A starts with DEF.
So if Column A starts with ABC or GHI, concatenate A,B,C,D,E,F into Column G.
But if Column A starts with DEF, concatenate A,B,C,D,F into Column G.
Does anyone know how to do this? I'm using the below Macro currently:
Sub ConcatCols_First()
'concatenate columns A to F in column G
Dim LastRow As Long
With Worksheets("Test")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
With .Range("G2:G" & LastRow)
.Formula = "=A2&B2&C2&D2&E2&F2"
.Value = .Value
End With
End With
End Sub
Everything in Column A starts with either ABC, DEF, or GHI, and I'd like the macro to skip Column E for rows where Column A starts with DEF.
So if Column A starts with ABC or GHI, concatenate A,B,C,D,E,F into Column G.
But if Column A starts with DEF, concatenate A,B,C,D,F into Column G.
Does anyone know how to do this? I'm using the below Macro currently:
Sub ConcatCols_First()
'concatenate columns A to F in column G
Dim LastRow As Long
With Worksheets("Test")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
With .Range("G2:G" & LastRow)
.Formula = "=A2&B2&C2&D2&E2&F2"
.Value = .Value
End With
End With
End Sub