ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Editing text (https://www.excelbanter.com/excel-programming/406510-editing-text.html)

donbowyer

Editing text
 
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

Gary''s Student

Editing text
 
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).
--
Gary''s Student - gsnu200770


"donbowyer" wrote:

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


JLGWhiz

Editing text
 
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" wrote:

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


donbowyer

Editing text
 
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" wrote:

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" wrote:

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



All times are GMT +1. The time now is 04:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com