View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
[email protected] wrethams@gmail.com is offline
external usenet poster
 
Posts: 17
Default conditional merging of two columns?

Thanks - the data isn't in columns A and B - how do I amend to reflect
this? Does A=1 and B=2 in your script?

On Mar 20, 11:35 am, "Mark Ivey" wrote:
Here is a quick one to suffice...

You will probably want to edit the FOR loop to accommodate the number of
rows needed. And maybe even the column references if your data is not in
column A and B. Please let me know if you need any help with this.

Mark

Sub test()

Dim row As Long

For row = 1 To 5
If Cells(row, 2).Text = "#N/A" Then
' Do nothing
Else: Cells(row, 1).Value = Cells(row, 2).Value
End If
Next

End Sub

wrote in message

...

I want to merge the two columns, sample data below:


CNM1GBLO #N/A
CNM1GBLO #N/A
CNP1GBLO #N/A
CNP1GBLO NIMWGBLO
CNQ1GBLO #N/A
CNR1GBLO #N/A
CNR1GBLO #N/A


What I want is for any value in the righthand column which is not
equal to #N/A to overwrite the value in the lefthand column on the
corresponding row.


So in this case, after the merge, column A would remain the same,
except that CNP1GBLO would now overwritten with NIMWGBLO.