View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JulieD JulieD is offline
external usenet poster
 
Posts: 618
Default Delete Part of Cell?

Hi Odysseus

try this code ...

Sub removeNY()
For Each cell In Range("Sheet1!M:M")
If cell.Value = "" Then Exit Sub
If Right(cell, 3) = " Y" Or Right(cell, 3) = " N" Then
cell.Value = Left(cell, Len(cell) - 1)
End If
Next
End Sub

Please feel free to post back if you need help "installing" it.

Hope this helps
Regards
JulieD


"Odysseus" wrote in message
...

Hi, I've been landed with a rather large project to re-write some
spreadsheets for my companies reports due to a new database... oh the
joys. I have no VBA experience and some basic macro usage. I've got 28
days to re-write about 10 worksheets so I may be popping in from time
to time to ask for some help.

My first question for today.

Can you delete part off a cell using a macro / VBA.

Example Cell from column (cost centre) :-

NTL089 N

I need to get rid of the N at the end, this could also be a Y. (yes or
no) This is used by certain departments for audit purposes so I can't
take it out of the DB export. Extra problems are that some may have
neither and some of the cost centres end in a Y or a N.

So the Macro needs to do a

If M column cells have a N or Y to the right preceded by 2 or more
spaces delete Y or N if not leave.

Does that make sense? Is it possible?

Thanks


--
Odysseus
------------------------------------------------------------------------
Odysseus's Profile:
http://www.excelforum.com/member.php...o&userid=14563
View this thread: http://www.excelforum.com/showthread...hreadid=274129