Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Hotkey that finds a character, then positions cursor on it?

The Excel cell contains text with a "-" minus sign embedded in it (e.g. a
phone number).
Q: Is there a Hotkey that will
1) "Find" the minus sign, and
2) Place the cursor right on top of that character?
Excel's "Find-and-Replace" doesnt work within the cell.

The macro I'm writing should massage the text in the following way:
1- (F2) Edit the text.
2- (How?) Find the minus sign, and position the cursor on top of it.
3- (Shft-Ctrl-End) Highlight all text from the minus sign to the end of
the cell.
4- (Ctrl-X) Cut the text.
5- (Tab, Ctrl-V) Move one cell to the right and paste the string.

Simple... I wish.

Thxs -
D.D.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Hotkey that finds a character, then positions cursor on it?

D.D.

Check out this recent thread (from last week) on how to do it.

http://groups.google.com/group/micro...bfb047eb8daaeb

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Hotkey that finds a character, then positions cursor on it?

Thanks for the prompt reply. I'll mull over the code and make it work. I
was hoping for a HotKey...
It seems odd to you that Excel lacks such a simple, common-sense feature
like this (aka "Find-while-in-Edit-Mode")?

Thanks - Dick Dixon

"Greg Glynn" wrote:

D.D.

Check out this recent thread (from last week) on how to do it.

http://groups.google.com/group/micro...bfb047eb8daaeb


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Hotkey that finds a character, then positions cursor on it?

Whilst Greg's posted link will do what you want, do you really need
select/cut ?
You know what the result should be, without user intervention, so code the
changes in VBA.

Private Sub CommandButton1_Click()
Dim HyphenPos As Long

With ActiveCell
HyphenPos = InStr(1, .Value, "-")
If HyphenPos 0 Then
.Offset(0, 1).Value = Mid(.Value, HyphenPos + 1)
.Value = Left(.Value, HyphenPos - 1)
End If
End With

End Sub



"D.D." wrote in message
...
The Excel cell contains text with a "-" minus sign embedded in it (e.g. a
phone number).
Q: Is there a Hotkey that will
1) "Find" the minus sign, and
2) Place the cursor right on top of that character?
Excel's "Find-and-Replace" doesnt work within the cell.

The macro I'm writing should massage the text in the following way:
1- (F2) Edit the text.
2- (How?) Find the minus sign, and position the cursor on top of it.
3- (Shft-Ctrl-End) Highlight all text from the minus sign to the end of
the cell.
4- (Ctrl-X) Cut the text.
5- (Tab, Ctrl-V) Move one cell to the right and paste the string.

Simple... I wish.

Thxs -
D.D.



  #5   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Hotkey that finds a character, then positions cursor on it?

D.D. - Also consider using a formula in the cell to the right of the phone
number in A5:

=RIGHT(A5,LEN(A5)-SEARCH("-",A5,1)+1) <<<includes the minus sign
=RIGHT(A5,LEN(A5)-SEARCH("-",A5,1)) <<<excludes the minus sign

--
Jay


"D.D." wrote:

The Excel cell contains text with a "-" minus sign embedded in it (e.g. a
phone number).
Q: Is there a Hotkey that will
1) "Find" the minus sign, and
2) Place the cursor right on top of that character?
Excel's "Find-and-Replace" doesnt work within the cell.

The macro I'm writing should massage the text in the following way:
1- (F2) Edit the text.
2- (How?) Find the minus sign, and position the cursor on top of it.
3- (Shft-Ctrl-End) Highlight all text from the minus sign to the end of
the cell.
4- (Ctrl-X) Cut the text.
5- (Tab, Ctrl-V) Move one cell to the right and paste the string.

Simple... I wish.

Thxs -
D.D.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Hotkey that finds a character, then positions cursor on it?

NickHK: You are correct. The expected outcome is known. I am a newbie at
VB but your code seems very compact, understandable and well within my
skillset. Thanks!

"NickHK" wrote:

Whilst Greg's posted link will do what you want, do you really need
select/cut ?
You know what the result should be, without user intervention, so code the
changes in VBA.

Private Sub CommandButton1_Click()
Dim HyphenPos As Long

With ActiveCell
HyphenPos = InStr(1, .Value, "-")
If HyphenPos 0 Then
.Offset(0, 1).Value = Mid(.Value, HyphenPos + 1)
.Value = Left(.Value, HyphenPos - 1)
End If
End With

End Sub



"D.D." wrote in message
...
The Excel cell contains text with a "-" minus sign embedded in it (e.g. a
phone number).
Q: Is there a Hotkey that will
1) "Find" the minus sign, and
2) Place the cursor right on top of that character?
Excel's "Find-and-Replace" doesnt work within the cell.

The macro I'm writing should massage the text in the following way:
1- (F2) Edit the text.
2- (How?) Find the minus sign, and position the cursor on top of it.
3- (Shft-Ctrl-End) Highlight all text from the minus sign to the end of
the cell.
4- (Ctrl-X) Cut the text.
5- (Tab, Ctrl-V) Move one cell to the right and paste the string.

Simple... I wish.

Thxs -
D.D.




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Hotkey that finds a character, then positions cursor on it?

Jay:
I am a BASIC programmer, but was unaware of the SEARCH function in VB. Your
solution is *really* compact, and effectively dodges the need to become VB
programmer in, say, the next 24 hours.... though it appears a mastry of VB is
inevitable! Thanks !

"Jay" wrote:

D.D. - Also consider using a formula in the cell to the right of the phone
number in A5:

=RIGHT(A5,LEN(A5)-SEARCH("-",A5,1)+1) <<<includes the minus sign
=RIGHT(A5,LEN(A5)-SEARCH("-",A5,1)) <<<excludes the minus sign

--
Jay


"D.D." wrote:

The Excel cell contains text with a "-" minus sign embedded in it (e.g. a
phone number).
Q: Is there a Hotkey that will
1) "Find" the minus sign, and
2) Place the cursor right on top of that character?
Excel's "Find-and-Replace" doesnt work within the cell.

The macro I'm writing should massage the text in the following way:
1- (F2) Edit the text.
2- (How?) Find the minus sign, and position the cursor on top of it.
3- (Shft-Ctrl-End) Highlight all text from the minus sign to the end of
the cell.
4- (Ctrl-X) Cut the text.
5- (Tab, Ctrl-V) Move one cell to the right and paste the string.

Simple... I wish.

Thxs -
D.D.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel2007 hotkey L@ja New Users to Excel 0 January 29th 08 12:23 PM
hotkey in usrform x taol Excel Programming 1 October 24th 06 10:26 AM
set cursor position to that last character hapt285 Excel Programming 0 March 30th 06 12:12 PM
Custom Hotkey Strategy Sprinks Excel Programming 2 December 29th 05 08:27 PM
Alt + Enter hotkey - what does this do? R Avery Excel Programming 2 October 14th 04 05:23 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"