+ Reply to Thread
Results 1 to 5 of 5

Using VBA to convert text to proper case

Hybrid View

  1. #1
    Registered User
    Join Date
    03-09-2007
    Posts
    51

    Using VBA to convert text to proper case

    Hi folks,

    I'm a complete novice with VBA (never done any coding before). I have a list of customers within excel but all the font is in both upper case and lower case.

    I need to use some coding to change the font to proper case in the cell range B2:J535 (i.e. all columns from B-J and all rows from 2-535)

    Is this possible? and if so can anyone shed any light on where to start? please put your responses in complete novice format because I am trying to start from scratch having never seen VBA before.

    Any assistance would be very much appreciated.

    Darlo

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    You can use this code (changing your font name, size, etc.):
    With Range("B2:J535 ")
       .Font.Name = "Arial"
       .Font.Size = 10
       .Font.Bold = False
    End With
    that is the same than write:
       Range("B2:J535 ").Font.Name = "Arial"
       Range("B2:J535 ").Font.Size = 10
       Range("B2:J535 ").Font.Bold = False
    Regards,
    Antonio

  3. #3
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454
    hi,

    right click the worksheet tab. Go to view code. Paste this -

    Sub ConvertCase()
    Dim rng As Range, x As Range
    
         If Selection.Cells.Count = 1 Then
            Set rng = ActiveSheet.UsedRange
        Else
           Set rng = Selection
        End If
       
              For Each x In rng
                  x = StrConv(x, vbProperCase)
              Next x
          
    End Sub
    into the window that pops up.

    Hilight all the cells you cant to work on, and goto toos>macros>run macros

    hth

    dave

  4. #4
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    I'm sorry but I misunderstood your question.

    Regards,
    Antonio

  5. #5
    Registered User
    Join Date
    03-09-2007
    Posts
    51
    Excellent, thank you!

    This has worked perfectly, sorry It has taken a while to reply but I have have had to format

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1