Trim the last two characters?

C

Craig

Hi folks,
I'm new to VBA, but I've programmed in VB (a little bit)
before. I have several cells that I simply need to trim
off the last 2 characters from. Is there a function in
Excel that can do that?...or does someone know of a
function that will do that? I frequently have something
like: 373.62CR and I need to keep the numeric portion, but
lose the text portion. Suggestions???

Thanks,
Craig
 
T

Tom Ogilvy

Is the CR produced by formatting or is this actually part of the value of
the cell. If you select the cell is it shown in the formula bar?

Assuming it is part of the text in the cell

Sub Remove2()
for each cell in selection
if not cell.Hasformula then
cell.Value = Left(cell.value,len(Cell.Value)-2)
end if
Next
End Sub

Assume the value is in A1, in B1 =Left(A1,len(A1)-2)

then drag fill down the column.
 
C

Craig

Hi Duane,
No, I haven't. Can you give me an example using the
Cells.Value concept (I don't quite understand the syntax
you've suggested), which is how I would be using it?

Thank you!
Craig
 
Top