View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Anders S[_2_] Anders S[_2_] is offline
external usenet poster
 
Posts: 57
Default 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/