Do PROPER case update, while pasting array, HOWTO?

Lexje

Active Member
Joined
Jul 6, 2004
Messages
264
Hi Everybody,

I'm working with an array as follows:

Code:
Dim cellRefs() As Variant
'Code to make a selection

    I = 1
    For Each cell In Selection
        'stores cell values in the array
        cellRefs(I) = cell.Value
    I = I + 1
    Next

'Code to add newsheet after activesheet and paste array to newsheet

    Sheets.Add After:=ActiveSheet
    Cells(2, 1).Select
    For I = 1 To numberOfCells
        ActiveCell.Value = cellRefs(I)
        ActiveCell.Offset(1, 0).Select
    Next I

This works allright, but I'd like to correct the text in the cells by converting it to PROPER case.
How would I add this to the above code?

Thanks for your help!!

Erwin
o_O
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Try this:

Code:
    For I = 1 To numberOfCells 
        ActiveCell.Value = WorksheetFunction.Proper(cellRefs(I)) 
        ActiveCell.Offset(1, 0).Select 
    Next I
 
Upvote 0
Thanks mdusoe!
Any way to do this while storing content in the array?
I ask this, because the array content is also used to fill a listbox.

Thanks a lot for your help!!

Erwin
 
Upvote 0
The following worked for me:

Dim myArr As Variant
Let myArr = Evaluate("transpose(proper(" & Selection.Address & "))")
MsgBox myArr(2)

You might want to test whether the selection is multi-celled and whether the range is vertical or horizontal... You may need to loop.

If you're looping through cells, try:

myArr(x) = StrConv(myRng.Value, vbProperCase)
 
Upvote 0
To use my scheme, but change it "on input", if you will, put this code into the first part...

Code:
For Each cell In Selection 
        'stores cell values in the array 
        cellRefs(I) = WorksheetFunction.Proper(cell.Value) 
    I = I + 1 
    Next

Now, your array has the case switched already, and you don't the Proper method on the paste part...

HTH,
Mike.
 
Upvote 0
Thanks a lot guys!!
This forrum really ROCKS!!!
Thanks a lot for the precious help :)

Erwin
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,435
Members
448,898
Latest member
dukenia71

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top