LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA question: Condense cell contents to first character

I have a column of first names that I want to condense down to the first
letter only (i.e. Chris becomes C). I have some code that I wrote, but it
doesn't work and I want to process every cell in that column that has a
value. Any help here would be appreciated...

Sub TrimText()
Dim FirstName As String

FirstName = ActiveCell.Text
If Len(FirstName) 1 Then
FirstName = Left(ActiveCell.Text, 1)
ActiveCell.Text = FirstName
End If
End Sub

Also, is it possible to create macros that aren't imbedded in each XLS file?
I'd like to have several files that I can run this macro on.

Sean


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert character at beginning of cell without changing contents elle Excel Discussion (Misc queries) 4 April 3rd 23 06:52 PM
Excel 2007 - Formatting text in cell (character by character) TomC Excel Discussion (Misc queries) 0 January 29th 10 07:25 PM
VBA Question: Move cell contents if... Scott Wagner Excel Programming 6 March 17th 06 10:03 PM
Another cell formatting dependent on cell contents question / message box popup? StargateFan[_3_] Excel Programming 2 January 14th 06 02:47 PM
macro to add alpha character to cell contents Janna[_3_] Excel Programming 2 August 5th 04 08:47 PM


All times are GMT +1. The time now is 08:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"