1

I'm creating a workbook that will automate the formatting process for customer service department at the non-profit I work for. They will copy/paste data into the workbook, run the procedures, then copy/paste out and import into their database.

One of the processes is taking fields such as first and last name, etc, and putting them into the "proper" or "title" case format. The code below is currently how I'm executing this process but I can't help but think that there has to be a more direct way. I've searched but to no avail.

Please lend me your wisdom!

'Proper Format
Range("AS1:BA" & myLR).FormulaR1C1 = "=PROPER(RC[-28])"
Range("BB1:BB" & myLR).FormulaR1C1 = "=PROPER(RC[-26])"

Range("Q2:Y" & myLR) = Range("AS2:BA" & myLR).Value
Range("AB2:AB" & myLR) = Range("BB2:BB" & myLR).Value

Columns("AS:BB").Delete Shift:= xlToRight
2
  • 3
    this is pretty good as is. You could load the ranges into an array, manipulate the array and rewrite the array to the range, but its probably not necessary with what you have. Jan 27, 2016 at 20:22
  • As @ScottHoltzman any other answer will require loops and depending on the data it will be slower than your method. Jan 27, 2016 at 20:34

1 Answer 1

3

Just in case you do want to loop through each cell, use this, it's pretty quick...

Sub Button1_Click()
    Dim MyLr As Long, rng As Range, c As Range

    MyLr = Cells(Rows.Count, "Q").End(xlUp).Row
    Set rng = Range("Q2:Y" & MyLr)

    For Each c In rng.Cells
        c = StrConv(c, vbProperCase)
    Next c

End Sub
1
  • Awesome, thanks for your response. I'll check it out! Jan 28, 2016 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.