Consulting

Results 1 to 11 of 11

Thread: Solved: CHANGE FROM ALL UPPER CASE

  1. #1
    VBAX Tutor GaryB's Avatar
    Joined
    Jun 2004
    Location
    Stockton, California
    Posts
    270
    Location

    Solved: CHANGE FROM ALL UPPER CASE

    Hi,

    I have a database that is to be used for a mailing list and it is all in uppercase. I need to do a global change to Upper and lower case. Anyone have an idea on how I can do this.

    Thanks

    Gary

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    For Eachcell In Activesheet.UsedRange
    cell.Value = UCase(cell.Value)
    Next cell
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Gary

    You don't actually say how you want to change the case but I think you might want to take a look at StrConv with the vbProperCase argument.

  4. #4
    VBAX Tutor GaryB's Avatar
    Joined
    Jun 2004
    Location
    Stockton, California
    Posts
    270
    Location
    My aplologies, I wasn't clear enough. I do want to change Proper Case but don't know enough VB to do it myself. I have a list of 800 names and address that are all capitalized and I need to change it to just the first letter of the word capitalized. I do have a way of doing this by importing it into Indesign as a comma, text delimited file, making the change there and importing it back into Excel. Which I have done. I was looking for a way to do it in Excel and eliminate about 4 steps to the process.

    Thanks,

    Gary

  5. #5
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    Gary,

    Combining XID's and Norie's suggestions gives

    [VBA]For Eachcell In Activesheet.UsedRange
    cell.Value = StrConv(cell.Value, 2) ' where 3 = vbProperCase
    Next cell [/VBA]

    Works very nicely on my very small sample. Areas that may be problems: hyphenated names (StrConv doesn't see "-" as a word separator) and Canadian and UK postal codes (mixed alphanumerics).

    Cheers!

  6. #6
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    Quote Originally Posted by RonMcK
    Gary,

    Combining XID's and Norie's suggestions gives

    [vba]For Eachcell In Activesheet.UsedRange
    cell.Value = StrConv(cell.Value, 2) ' where 3 = vbProperCase
    Next cell [/vba]
    Works very nicely on my very small sample. Areas that may be problems: hyphenated names (StrConv doesn't see "-" as a word separator) and Canadian and UK postal codes (mixed alphanumerics).

    Cheers!
    Darn typo. That should be
    StrConv(cell.Value, 3)

  7. #7
    VBAX Tutor GaryB's Avatar
    Joined
    Jun 2004
    Location
    Stockton, California
    Posts
    270
    Location
    Quote Originally Posted by RonMcK
    Darn typo. That should be
    StrConv(cell.Value, 3)
    When I created a macro and put this code into it I get a compile error
    syntax error
    This is what I did for the macro.
    [VBA]Sub UPPERCASE()
    For Eachcell In Activesheet.UsedRange
    cell.Value = StrConv(cell.Value, 2) ' where 3 = vbProperCase
    Next cell
    End Sub[/VBA]

    Thanks

    Gary

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Sub UPPERCASE()
    For Each cell In Activesheet.UsedRange
    cell.Value = StrConv(cell.Value, 3) ' where 3 = vbProperCase
    Next cell
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    VBAX Tutor GaryB's Avatar
    Joined
    Jun 2004
    Location
    Stockton, California
    Posts
    270
    Location
    Thanks Everyone,

    The last entry by El Xid did it. Worked like a charm.

    Gary

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That wasn't by me, I just spotted the missing space.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  11. #11
    VBAX Tutor GaryB's Avatar
    Joined
    Jun 2004
    Location
    Stockton, California
    Posts
    270
    Location
    Quote Originally Posted by xld
    That wasn't by me, I just spotted the missing space.
    Sorry,
    Didn't mean to take anything away from Ron. I was refering to the fix in the code you spotted. Any Way,

    Thanks again to everyone.

    Gary

Posting Permissions

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