Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I repeat key strokes in Excel?

I tried recording the following macro.
F2 - Select current cell
Shift arrow left
backspace - (to delete one character)
shirt arrow left
backspace - (to delect one character)
enter - which advance to next cell down.

instead the macro records the value that I was working with after the 2
backspaces, instead I want it to perform the key strokes as entered.

Please help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How do I repeat key strokes in Excel?


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

--

HTH

RP
(remove nothere from the email address if mailing direct)


"ross_76102" wrote in message
...
I tried recording the following macro.
F2 - Select current cell
Shift arrow left
backspace - (to delete one character)
shirt arrow left
backspace - (to delect one character)
enter - which advance to next cell down.

instead the macro records the value that I was working with after the 2
backspaces, instead I want it to perform the key strokes as entered.

Please help.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default How do I repeat key strokes in Excel?

Ross,

You can't record or code keystrokes to edit a cell. This truncates the two
cells to the left of the active cell, stripping the rightmost character:

Sub test()

With ActiveCell.Offset(0, -1)
.Value = Left$(.Value, Len(.Value) - 1)
End With
With ActiveCell.Offset(0, -2)
.Value = Left$(.Value, Len(.Value) - 1)
End With

End Sub

hth,

Doug

"ross_76102" wrote in message
...
I tried recording the following macro.
F2 - Select current cell
Shift arrow left
backspace - (to delete one character)
shirt arrow left
backspace - (to delect one character)
enter - which advance to next cell down.

instead the macro records the value that I was working with after the 2
backspaces, instead I want it to perform the key strokes as entered.

Please help.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default How do I repeat key strokes in Excel?

Here is some code to do what you have ascked...

Public Sub TrimLast2()
With ActiveCell
If Len(.Value) = 2 Then
.Value = Left(.Value, Len(.Value) - 2)
.Offset(1, 0).Select
End If
End With
End Sub

HTH

"ross_76102" wrote:

I tried recording the following macro.
F2 - Select current cell
Shift arrow left
backspace - (to delete one character)
shirt arrow left
backspace - (to delect one character)
enter - which advance to next cell down.

instead the macro records the value that I was working with after the 2
backspaces, instead I want it to perform the key strokes as entered.

Please help.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do I repeat key strokes in Excel?



"ross_76102" wrote:

I tried recording the following macro.
F2 - Select current cell
Shift arrow left
backspace - (to delete one character)
shirt arrow left
backspace - (to delect one character)
enter - which advance to next cell down.

instead the macro records the value that I was working with after the 2
backspaces, instead I want it to perform the key strokes as entered.

Please help.


You'll need a macro for this. If I understand you correctly, you may be
able to use something like this ...


sub takeoffmyval()
dim c as range, s as range
set s = selection
for each c in s
c.value = trim(left(c.value, len(c.value) - 2))
next
end sub


Note this takes some assumptions into hand. Save your work before running.
To run:

From Excel press Alt + F11.
Press Ctrl + R
Select (Bold) file on left pane.
Select Insert (menu) | Module
Copy/Paste code above on right pane.
Alt + Q will return to Excel.
Ctrl + S will Save your workbook.
Alt + F8 will bring up the Macro dialog box.
Select 'takeoffmyval'.
Click Run.

HTH


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default How do I repeat key strokes in Excel?

If you are just wanting to remove the last two characters from a field you
could use a formula like this: =LEFT(A2,LEN(A2)-2)

Or if you want to do it via a macro this will do the same thing:

activecell.value = left(activecell.Value,len(activecell.Value)-2)

Hope this helps
Rowan

"ross_76102" wrote:

I tried recording the following macro.
F2 - Select current cell
Shift arrow left
backspace - (to delete one character)
shirt arrow left
backspace - (to delect one character)
enter - which advance to next cell down.

instead the macro records the value that I was working with after the 2
backspaces, instead I want it to perform the key strokes as entered.

Please help.

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
what are the keyboard strokes to reveal formulas in a worksheet? Steve2788 Excel Worksheet Functions 3 November 6th 08 05:50 AM
Slow Respone to key strokes Keith Excel Discussion (Misc queries) 4 December 6th 07 12:08 AM
Slow respone to key strokes Keith Excel Discussion (Misc queries) 1 December 5th 07 11:59 PM
Is there a way to move between worksheets using key strokes only? John Parker Excel Discussion (Misc queries) 3 December 30th 06 12:16 AM
How can I activate a combobox by keyboard strokes ? Oscar Excel Programming 11 January 4th 04 04:25 AM


All times are GMT +1. The time now is 06:15 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"