ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I repeat key strokes in Excel? (https://www.excelbanter.com/excel-programming/328147-how-do-i-repeat-key-strokes-excel.html)

ross_76102

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.

Bob Phillips[_6_]

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.




Don Guillett[_4_]

How do I repeat key strokes in Excel?
 
What are you trying to do?

--
Don Guillett
SalesAid Software

"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.




Doug Glancy

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.




Jim Thomlinson[_3_]

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.


Zack Barresse[_2_]

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



Rowan[_2_]

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.



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

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