 | I am using the following VBA code to concatenate two columns of data: VBA Code:
Sub Combine_Columns() Dim modifier As Variant Dim word As Variant
Range("F4").Select 'Change as appropriate
For Each word In Range("D4", Range("D4").End(xlDown)) For Each modifier In Range("B4", Range("B4").End(xlDown)) ActiveCell.Formula = modifier & " " & word ActiveCell.Offset(1, 0).Select Next Next Range("F4").Select
End Sub
|
This works great as long as there is more than 1 word in each column; However, when there is only one word in either column the macro will run indefinitely (combining words with blank cells). I've tried fixing this using a series of If statements, but I still can't get it to work (or at the very least prompt the user that more than 2 words must be used)
Any help that you can offer would be much appreciated.
|