Pls have a look at my algorithm. I’m trying to merge two columns’ data into one and place the result in another column.
Sub Combine_Ports()
Dim CurSheet, PortCode As String
Dim i As Long
CurSheet = ActiveSheet.Name
Worksheets(“Port”).Activate
For i = 2 To 11
PortCode = Range(“A” & i).Value
If Range(“D” & i).Value = PortCode Then
Range(“B” & i).Value = Range(“C” & i).Value & Range(“D” & i).Value
Exit For
End If
Next i
Worksheets(CurSheet).Activate
End Sub
Here is what the excel sheet look like:
ColA ColB ColC ColD
SING SG SIN
BRV DE BRV
RTM NL RTM
ANR BE ANR
HAM DE HAM
SOU GB SOU
LEH FR LEH
GNK IT GOA
BCN ES BCN
FOS FR FOS
I made a mistake by referencing to ColumnA. There are exceptions. I don’t want to make reference to ColumnA anymore. I just want to combine ColumnC and ColumnD, and place result in Column B.
Pls correct my algorithm. Thank you.