View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default IF cell does not contain certain value move to right

I'm guessing you didn't mean, for example WS and ES... I'm guessing you want
this to be for the standard directional abbreviations (such as, SW and SE).
Assuming that is the case, does this code do what you want?

Dim R As Range
For Each R In Range("B1:B" & CStr(Cells(Rows.Count, 1).End(xlUp).Row))
If Not (R.Value Like "[NSWE]" Or R.Value Like "[NS][EW]") Then
R.Offset(0, 1).Value = R.Value
R.Value = ""
End If
Next

Rick


"saman110 via OfficeKB.com" <u35670@uwe wrote in message
news:7a187cbfec6b4@uwe...
Hello all.

I am looking for a macro that looks in Col. B and if each cell does
contain
anything other than N, S, W, E, NE, NW, SW, SE, WN,WS, ES, EN would move
it
to the right.

ex.

Col. A Col. B
1 N
2 Sam
3 W
4 Tom
5 NE


Result:

Col. A Col. B Col. C
1 N
2 Sam
3 W
4 Tom
5 NE




Thx.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200710/1