Results 1 to 26 of 26

Force text to Uppercase in active cells

Threaded View

  1. #1
    Forum Contributor
    Join Date
    03-22-2006
    Location
    UK
    MS-Off Ver
    Office 2013
    Posts
    275

    Force text to Uppercase in active cells

    Hi all

    To ensure correct data entry, I need to ensure that the filled cells in a column are always in Uppercase for example, irrespective of whether they are typed in upper or lower case.

    I have found the following code, which seems to work quite well, even though I have the impression that it slowed my workbook down slightly.

    Private Sub Worksheet_Change(ByVal Target As Range)
     
    If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub
     
        On Error Resume Next
     
        If Not Intersect(Target, Range("D:D,F:F")) Is Nothing Then
     
            Application.EnableEvents = False
     
            Target = UCase(Target)
     
            Application.EnableEvents = True
     
        End If
     
        On Error GoTo 0
    End Sub
    Firstly, I would like to know if the code could be amended so that it only works on the cells in a column from the top of the column (either D1 or D2 down to the last occupied or active cell in that column.

    Secondly, is it possible to have a combined code that also creates a capitalised word for each word in a column but for different specified colums.

    In other words, if you have an address list where columns A, B, C & D are used for the main parts of the address; these would need the 1st letter to be capitalised and then Column E would contain the postcode, which needs to all in uppercase.

    This code would need to be used in various worksheets within one workbook on different columns and I fopund the above code was very easy to customise by changing the column reference.

    TIA ...spellbound
    Last edited by VBA Noob; 01-28-2009 at 03:35 PM.

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