Coping Cells With A Loop

Solved/Closed
froggy6703 Posts 16 Registration date Tuesday March 23, 2010 Status Member Last seen March 29, 2013 - Apr 6, 2010 at 09:39 PM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Apr 7, 2010 at 05:52 AM
Hello,

I am stumped on what should be a very simple macro. I am running a macro that is using a look-up table to compare the values in column G. The results from the look-up table are then added to column F. If a value wasn't match I am getting a value of "N/A" in that cell. Now that I have that part completed I am trying to write a macro that would look at Column F If the cell doesn't contain the value of "N/A", it will copy the value of that cell in column F to the corresponding cell in column G. But if the cell contains a value of "N/A", it will skip over this cell and go to the next cell.

Example...

Before
Column F Column G
123ABC 123_ABC
N/A 234_BCD
345CDE 345_CDE

After
Column F Column G
123ABC 123ABC
N/A 234_BCD
345CDE 345CDE

Any help would be greatly appreciated.

Thank you,

Matt


Related:

1 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Apr 7, 2010 at 05:52 AM
You are messing up with the existing data. copy the data somewhere so that it can be retrieved.

your data is like this

hdng 1 hdng 2
123ABC 123ABC
N/A 234_BCD
345CDE 345CDE

try this macro
Sub test()
Dim r As Range, c As Range
Set r = Range(Range("A2"), Range("A2").End(xlDown))
For Each c In r
If c <> "N/A" Then
c.Offset(0, 1) = c
End If
Next c

End Sub
0