View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Stephen Ford Stephen Ford is offline
external usenet poster
 
Posts: 3
Default Need VB code to edit cell values

This works
With ActiveCell
.Value = Right(.Offset(0, -1).Value, 3)
.Offset(0, -1).Value = Left(.Offset(0, -1).Value,
Len(.Offset(0, -1).Value) - 3)
End With
ActiveCell.Offset(1, 0).Activate

It changes
CellX CellY
A03001 XXX (before)
A03 001 (after)

The code ".Offset(0, -1).Value" is repeated a lot. Can a variable / object
or whatever be assigned and used instead?

CellY is text. If is gets a value like "001" the cells shows an error. I can
use the mouse to Ignore Error. Can this be programmed or can the error be
avoided another way?

"Stephen_Ford net" <stephen_fordNO@SPAMuwclub<dot wrote in message
...
Yes, I think that's it. I'll check... back soon.

"Rick Rothstein" wrote in message
...
I'm not sure if I completely understand your question... does this code
do what you want?

With ActiveCell
.Offset(0, -1).Value = Left(.Value, Len(.Value) - 3)
.Value = Right(.Value, 3)
End With

--
Rick (MVP - Excel)


"Stephen Ford" wrote in message
...
I need some VB to do the following please (My VB is not good enough yet)

Starting from the active cell (call it the StartCell)
In the cell to the left..
ThreeChars = Value.right(3) (the last three chars)
Value = Value - last three characters (assume value is text & at least 3
chars present)
In StartCell..
value = ThreeChars (as text, overwrite any contents of StartCell)
move active cell one down from StartCell