ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Relative Macro Assignment (https://www.excelbanter.com/excel-programming/296190-relative-macro-assignment.html)

esskaykay

Relative Macro Assignment
 
I have a generic MACRO question. I undestand the relative/absolut
principle. However, when using the "Record a new macro" option, an
set the macro to Relative, it does not appear to be repeating the sam
key stokes I typed.

Example-
Say I have a column of text and I want to delete the second characte
of each cell. I clicked Record amacro, set to relative, then keyed:

Edit, Home, Right, Delete, Enter

Then stopped recording. If my original column is:

Dog
Cat
Mouse

I want

Dg
Ct
Muse

But I get
Dg
Dg
Dg

Thanks,
SK

--
Message posted from http://www.ExcelForum.com


Anders S[_2_]

Relative Macro Assignment
 
Hi,

Whatever you do when you are in cell edit mode is *not* recorded by the macro
recorder, just the result when you press Enter, so what you get is 'Enter "Dg"
in the cell', *not* 'delete the second character in the cell'.

Try the following macro, it deletes the second character in each selected cell,
assuming the selected cells contain text strings. You can change Selection to
any range.

'-----
Option Explicit

Sub test637()
Dim cCell As Range
For Each cCell In Selection
With cCell
.Value = Left(.Value, 1) & Mid(.Value, 3)
End With
Next
End Sub
'-----

HTH
Anders Silven

"esskaykay " skrev i meddelandet
...
I have a generic MACRO question. I undestand the relative/absolute
principle. However, when using the "Record a new macro" option, and
set the macro to Relative, it does not appear to be repeating the same
key stokes I typed.

Example-
Say I have a column of text and I want to delete the second character
of each cell. I clicked Record amacro, set to relative, then keyed:

Edit, Home, Right, Delete, Enter

Then stopped recording. If my original column is:

Dog
Cat
Mouse

I want

Dg
Ct
Muse

But I get
Dg
Dg
Dg

Thanks,
SKK


---
Message posted from http://www.ExcelForum.com/



esskaykay[_2_]

Relative Macro Assignment
 
Thanks for your response Anders.

What I really wanted to know was 'why do I lose my routine afte
entering the Edit mode?' (you answered that). I remember the old Lotu
macro language where you could enter commands directly as the macr
code. Too bad that's gone, particularly for us non-VB progammers.
realize how much more powerful VBA is, however most of the things
want to antomate could be done with simple key stroke commands. O
well, that's progress...

Thanks again,
SK

--
Message posted from http://www.ExcelForum.com


Anders S[_2_]

Relative Macro Assignment
 
Hi again,

Thanks for the feedback. Hope you find a way to get on.

Regards
Anders Silven

"esskaykay " skrev i meddelandet
...
Thanks for your response Anders.

What I really wanted to know was 'why do I lose my routine after
entering the Edit mode?' (you answered that). I remember the old Lotus
macro language where you could enter commands directly as the macro
code. Too bad that's gone, particularly for us non-VB progammers. I
realize how much more powerful VBA is, however most of the things I
want to antomate could be done with simple key stroke commands. Oh
well, that's progress...

Thanks again,
SKK


---
Message posted from http://www.ExcelForum.com/




All times are GMT +1. The time now is 03:17 AM.

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