# I havComparing two columns and get the resulte three columns

Hi!

I have problem coding between two columns and third with result

Let’s say

Column E = Destination

Column F=ORIGIN

And Column G Should contain RP/ARRIVAL

Or SPOT TIME It depends from the destination

Thank you!

Top Contributor Asked on November 18, 2017 in

You can create similar file with dummy data I don’t think it is difficult

Can you point to the line that the error occurs at?

Expert Answered on November 18, 2017.

Yes!! I’ll try dummy I think it’s going to be more easy to get what I need! Thanks!!! 🙂

on November 18, 2017.

Hello

Can you give more details and attach sample of your workbook with some desired output?

Expert Answered on November 18, 2017.

Column  E is Origin

Column F is Destination

Column G may be RP TIME/SPOT TIME/TMR RELEASE

G depends of which is the origin and what I have to track.

Let’s say

Origin=Kuwait

Destination=Macedonia

G should be RP TIME

Or if

Origin = Macedonia

Destination=Majami

G should be SPOT TIME

I hope am easy to understand now 🙂

Top Contributor Answered on November 18, 2017.

And thank you! 🙂

Top Contributor Answered on November 18, 2017.

Try this code

```Sub Test()
Dim i As Long
Dim m As Long
m = Cells(Rows.Count, 5).End(xlUp).Row
For i = 2 To m '2 First Row Of Data. I Supposed Row 1 For Headers
If Cells(i, 5) = "Kuwait" And Cells(i, 6) = "Macedonia" Then
Cells(i, 7) = "RP TIME"
ElseIf Cells(i, 5) = "Macedonia" And Cells(i, 6) = "Majami" Then
Cells(i, 7) = "SPOT TIME"
Else
Cells(i, 7) = ""
End If
Next i
End Sub
```
Expert Answered on November 18, 2017.

Thank you!! I will and I’ll let you know 🙂

Top Contributor Answered on November 18, 2017.

You’re welcome

Glad I can offer some help

Expert Answered on November 18, 2017.

Thank you! It runs, Ill try some others stuff that I need to add for matching, but I have another problem now, I had a diffrent code I set the macro to run whenever I open the work book but now it gives me error of function or variable on my mobule 🙁 so I have to run it manual

Top Contributor Answered on November 18, 2017.

You’re welcome

It will be better to upload sample of your workbook to see the error ..

Try to declare all the variables in your codes so as to avoid errors

Expert Answered on November 18, 2017.

I cannot upload a file, at least I don’t see permission for that 🙂

Top Contributor Answered on November 18, 2017.

Expert Answered on November 18, 2017.

I am trying dummy now so I hope I’ll get what I need. Thanks!!

Top Contributor Answered on November 18, 2017.
• ## Found this useful?

Please share using the share button above.