![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
I am trying to write/record a macro that will eliminate a space at the end of each number. On a one-at-a-time basis, if you go to a cell, hit F2, left one space, shift-end delete and enter, the data in the cell is converted to a number. However, when I record a macro following those keystrokes, the macro enters the number contained in the cell on which the macro was recorded, not the number in the current active cell. I'm not sure what I should do to have the macro read the current cell's contents. (I clicked the relative reference button, but that's not solving the problem)
Any help would be greatly appreciated. |
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Quote:
|
|
|
|
|
|
|
#3 |
|
Guest
Posts: n/a
|
Thanks to Aladin Ayurek for this solution:
The last character in the cell is a number, which has the ascii code char(202) or in some other cases char(160). So the answer is : =if(isnumber(left(c4)+0), substitute(c4,char(160)" ")+0) (For some reason, the char(160) works on either code) |
|
|
|
#4 | |
|
Guest
Posts: n/a
|
Quote:
|
|
|
|
|
#5 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Hi
Once you know the character set you can simply use some east code like this: Selection.Replace What:="" & Chr(10) & "", _ Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False Or you can just type the character code in the Find box and leave the Replace empty. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|