View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Deleting last letter if a cell

dim myStr as string

mystr = ".5D + 2L + 3W + "
'extra spaces, too

mystr = trim(mystr) 'gets rid of leading and trailing spaces

if right(mystr,1)="+" then
mystr = trim(left(mystr,len(mystr)-1))
'also cleans up trailing spaces with the trim.
end if

msgbox "***" & mystr & "***"



Kevin O'Neill wrote:

What I'd like to do is, if the last letter of what is inputed into a
cell is the "+" symbol. Then delete it.

I have a cell defined by:
Sheet12.Cells(11, 2) = d & "+" + l & "+" + w & "+" + s

Here's what i get fromt that cell.
.5D + 2L + 3W + 2S

if i change it and s = 0 i get
.5D + 2L + 3W +

i want to get
.5D + 2L + 3W

So i was hoping maybe there was a command, to delete a space off the
end of a cell using and IF statement.

IF last letter is a "+" , delete 1-2 spaces of the end of the cell.


--

Dave Peterson