ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to append En Spaces (https://www.excelbanter.com/excel-programming/342233-macro-append-en-spaces.html)

Dan[_48_]

Macro to append En Spaces
 
Hi,

I'm trying to write a macro that will append special characters (two en
spaces) to the beginning of the text in each highlighted cell. I am new
to vba, and I am not having much luck. Does anyone have any ideas or
hints for how to do this?

Thanks,
Dan


Jake Marx[_3_]

Macro to append En Spaces
 
Hi Dan,

Dan wrote:
I'm trying to write a macro that will append special characters (two
en spaces) to the beginning of the text in each highlighted cell. I
am new to vba, and I am not having much luck. Does anyone have any
ideas or hints for how to do this?


I don't know the character code for an en space, but here's some code that
should do what you're looking for (replace 50 with the character code that
corresponds to en space):

Public Sub gPrependEmSpaces()
Dim c As Range

For Each c In Selection
If Len(c.Value) 0 And Not c.HasFormula Then
c.Value = Chr(50) & Chr(50) & c.Value
End If
Next c
End Sub

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]




All times are GMT +1. The time now is 01:18 PM.

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