Results 1 to 7 of 7

Thread: Excel - Macro Help (Capitalization of the ENTIRE first word)

  1. #1
    Join Date
    Jul 2009
    Posts
    4

    Excel - Macro Help (Capitalization of the ENTIRE first word)

    I am currently using this macro to capitalize the first letter of the word in excel. . .

    Code:
    Sub CapFirstWord()
    'by Ed Weber 09/19/07
    ' Select continuous rows in the same column which contain the target text
    Dim ActSh As Worksheet
    Set ActSh = ActiveSheet
    Dim temp As String
    Dim strText As String
    Dim oCell
    temp = ""
    For Each oCell In Selection.Cells
    If IsEmpty(oCell) = False Then
    strText = Trim(oCell.Value)
    temp = UCase(Mid(strText, 1, 1))
    strText = temp & Mid(strText, 2, Len(strText) - 1)
    oCell.Value = ""
    oCell.Value = strText
    temp = ""
    End If
    Next oCell
    End Sub

    What I want to do is capitalize the first entire WORD in a cell with a similar macro. Basically if the cell has multiple words in the cell, for example a last name, first name. . .I want the entire last name capitalized. So it would be something like. . .

    Smith, John

    When you run the macro on selected cells it would change it to. . .

    SMITH, John


    Any advice/help is greatly appreciated! Thank you!!!

  2. #2
    Join Date
    Jan 2009
    Posts
    576

    Re: Excel - Macro Help (Capitalization of the ENTIRE first word)

    This macro will capitalize the first letter of any selected cell in Excel.try here
    How to capitalize first letter of every word in Excel

    Edit: Try this too:

    Convert text to uppercase/lowercase using Macros

  3. #3
    Join Date
    Jul 2009
    Posts
    4

    Re: Excel - Macro Help (Capitalization of the ENTIRE first word)

    Not asking for capitalizing the first letter in the word in a given cell.

    The macro code I pasted already does that. I want to know how to capitalize the ENTIRE FIRST WORD in any given cell with the use of a macro.

  4. #4
    Join Date
    Jul 2009
    Posts
    4

    Re: Excel - Macro Help (Capitalization of the ENTIRE first word)

    Is there anyone that could possibly adapt the code in the OP so that it capitalizes the first entire WORD and not just simply the first letter?

    Thank you in advance for any help!

  5. #5
    Join Date
    Oct 2008
    Posts
    93

    Re: Excel - Macro Help (Capitalization of the ENTIRE first word)

    Sample macro code to change the case of text in Excel

    Macro to Change All Text in a Range to Uppercase Letters

    Code:
    Sub Uppercase()
       ' Loop to cycle through each cell in the specified range.
       For Each x In Range("A1:A5")
          ' Change the text in the range to uppercase letters.
          x.Value = UCase(x.value)
       Next
    End Sub
    Macro to Change All Text in a Range to Lowercase Letters

    Code:
    Sub Lowercase()
       ' Loop to cycle through each cell in the specified range.
       For Each x In Range("B1:B5")
          x.Value = LCase(x.Value)
       Next
    End Sub
    Macro to Change All Text in a Cell Range to Initial Capital Letters

    Code:
    Sub Proper_Case()
       ' Loop to cycle through each cell in the specified range.
       For Each x In Range("C1:C5")
          ' There is not a Proper function in Visual Basic for Applications.
          ' So, you must use the worksheet function in the following form:
          x.Value = Application.Proper(x.Value)
       Next
    End Sub

  6. #6
    Join Date
    Jan 2009
    Posts
    576

    Re: Excel - Macro Help (Capitalization of the ENTIRE first word)


  7. #7
    Join Date
    Jul 2009
    Posts
    4

    Re: Excel - Macro Help (Capitalization of the ENTIRE first word)

    Thank you for your quick replies.

    ALTHOUGH. . .

    I'm still looking to just simply capitalize the first word in each cell. The entire first word, not all of it and not just the first letter.

    For example;

    Smith, John.

    -to-

    SMITH, John.

    Thanks in advance! I appreciate the help, just hope this is possible through a quick dirty macro of some sort.

Similar Threads

  1. Excel 2003 Macro doesn't work in Excel 2007
    By jjaw in forum Windows Software
    Replies: 3
    Last Post: 03-01-2014, 03:28 PM
  2. Excel and capitalization
    By Deabelos in forum Windows Software
    Replies: 4
    Last Post: 16-01-2012, 08:01 PM
  3. Copy Entire Media List To Excel Or Word
    By ASHER in forum Windows Software
    Replies: 4
    Last Post: 19-04-2010, 10:44 AM
  4. Excel: format data capitalization
    By AdityaR in forum Windows Software
    Replies: 3
    Last Post: 11-06-2009, 07:09 PM
  5. Macro for hyperlink on Word/Excel
    By Mindstorm in forum Windows Software
    Replies: 3
    Last Post: 07-05-2009, 03:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,058,582.62189 seconds with 17 queries