Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Oct 2008
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    proper function (Excel 2003)

    I am back for some more advise. In the attached example I found in Peter Noneleys Excel Function Dictionery I am interested if there is a way to achieve the same result without creating another column?

    Regards
    B
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: proper function (Excel 2003)

    You could use VBA code to convert cell entries to proper case as they are entered, but this has some disadvantages:
    - Users have to enable macros, otherwise it won't work.
    - Undo will be disabled, so users can't undo mistakes easily.

    If you want to try it out:
    - Right-click the sheet tab.
    - Select View Code from the popup menu.
    - Copy the following code into the module that appears:

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim oCell As Range
    If Not Intersect(Range("C4:C8"), Target) Is Nothing Then
    For Each oCell In Intersect(Range("C4:C8"), Target).Cells
    oCell = StrConv(oCell, vbProperCase)
    Next oCell
    End If
    End Sub

    - You can modify the range C4:C8 if desired.
    - Switch back to Excel.
    - Edit one of the cells in C4:C8. As soon as you confirm the change, the value will be converted to proper case.

  3. #3
    New Lounger
    Join Date
    Oct 2008
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: proper function (Excel 2003)

    I have done this and it works. Thankyou - Hans how can I make this macro work without having to edit the cells? I want to apply it to a spreadsheet that has data already entered. If it is too hard, I can always insert another column as in the example I attached in the beginning and simply hide it I suppose.

    Regards
    B

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: proper function (Excel 2003)

    Edited by HansV to correct error - thanks to Legare Coleman for alerting me

    You could create the following macro in a standard module (not in the worksheet module):

    Sub MakeProper
    Dim oCell As Range
    For Each oCell In Selection
    oCell = StrConv(oCell, vbProperCase)
    Next oCell
    End Sub

    Select a range of cells and run the macro.
    Warning: don't select cells with formulas, the macro would replace the formulas with their values.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: proper function (Excel 2003)

    Legare Coleman suggested the following improved version, which skips cells with a formula:

    Sub MakeProper()
    Dim oCell As Range
    For Each oCell In Selection
    If Not oCell.HasFormula Then
    oCell = StrConv(oCell, vbProperCase)
    End If
    Next oCell
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •