Editing text

D

donbowyer

WinXP Excel 2003
Is it possible to programmicatically determine the position of the Cursor in
a text string in a cell - eg as a count to the Right from the 1st character
in the cell?

Also, I have a macro which places a Tab code [Chr(9)] in a string.
If I then try to manually edit the text (double click the cell), I see that
the Cursor has been tabbed ok, but any text I then enter ignores the tab and
is placed immediately after the last character in the string.
Is there any way to overcome this.

donwb
 
G

Gary''s Student

First put data in a cell (either with VBA or manually).
Next double-click the cell.

If you double-click near the right boundary of the cell, the edit cursor
will appear near the end of the data. If you double-click near the left
boundary of the cell, the edit cursor will appear near the beginning of the
data.

You can, from VBA, programmatically enter edit mode in a cell with the edit
cursor exactly positioned, but it requires SendKeys (which many prudent
people avoid).
 
J

JLGWhiz

There are several ways to handle the first question. Look up the Mid, Left,
Right and Characters functions in VBA help.

I don't quite understand your second problem, except that cell edititing has
certain protocol.
 
D

donbowyer

Thanks for the responses.
First Q.
So what is the correct syntax for something like
MyPosition=ActiveCell.CursorPosition
mindful that the cell will, by definition, have to be in the Edit mode.
Second Q.
The macro I discussed Tabs the Cursor from the last character in the cell to
a position just right of the last character. That's fine.
When the macro's finished, a DoubleClick on the cell clearly shows the new
Cursor position. But if I then enter new text, then hit Return, the new text
is not at the Tabbed Cursor position, but back to just after the original
text's last character.

--
donwb


JLGWhiz said:
There are several ways to handle the first question. Look up the Mid, Left,
Right and Characters functions in VBA help.

I don't quite understand your second problem, except that cell edititing has
certain protocol.

donbowyer said:
WinXP Excel 2003
Is it possible to programmicatically determine the position of the Cursor in
a text string in a cell - eg as a count to the Right from the 1st character
in the cell?

Also, I have a macro which places a Tab code [Chr(9)] in a string.
If I then try to manually edit the text (double click the cell), I see that
the Cursor has been tabbed ok, but any text I then enter ignores the tab and
is placed immediately after the last character in the string.
Is there any way to overcome this.

donwb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top