VBA Code for Proper Case in Selected Cells

Here's a VBA code snippet that will convert the text in the selected cells to Proper Case (where the first letter of each word is capitalized):


Sub ConvertToProperCase()
    Dim rng As Range
    Dim cell As Range

    ' Set the range to the selected cells
    Set rng = Selection

    ' Loop through each cell in the selected range
    For Each cell in rng
        ' Check if the cell contains text
        If Not IsEmpty(cell.Value) Then
            cell.Value = Application.WorksheetFunction.Proper(cell.Value)
        End If
    Next cell
End Sub


How to Use This Code:

  1. Press ALT + F11 to open the VBA editor.
  2. Go to Insert > Module to insert a new module.
  3. Copy and paste the code into the module.
  4. Close the VBA editor.
  5. Select the cells you want to convert to Proper Case.
  6. Press ALT + F8, select ConvertToProperCase, and click Run.

This will change the text in the selected cells to Proper Case.



Mani Blogs

Welcome to my blog! I am Manender, an ecommerce expert with over 7 years of experience. Throughout my career, I've specialized in bulk data scrapping, become an Excel pro, and offered top- notch IT solutions. My knowledge extends to platforms like Shopify, Magento, Amazon, Flipkart, and more. Join me on this exciting journey as we uncover ecommerce secrets, optimize user experiences, and boost sales. Together, we'll create thriving online businesses in this dynamic digital marketplace. Stay tuned for actionable insights, tips, and tricks to achieve ecommerce excellence! Thank you for being part of this amazing community. Let's thrive in ecommerce!

Post a Comment

Previous Post Next Post