Consulting

Results 1 to 4 of 4

Thread: Solved: Selection Caps Locks

  1. #1

    Solved: Selection Caps Locks

    I have this code that capitalizes the cell. Problem I'm facing it continuously loops because there is a change. Is there another ways of doing thins via VBA?

    [VBA]Private Sub Worksheet_Change(ByVal Target As Range)
    Target.Activate
    Selection.Value = UCase(ActiveCell.Value)
    End Sub
    [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [VBA]Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cell As Range

    On Error GoTo ws_exit

    Application.EnableEvents = False

    For Each cell In Target

    cell.Value = UCase(cell.Value)
    Next cell

    ws_exit:
    Application.EnableEvents = True
    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

  3. #3
    Thank XLD

  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    [VBA]Private Sub Worksheet_Change(ByVal Target As Range)
    if target<>Ucase(target) and vartype(target)=8 then target= UCase(Target)
    End Sub[/VBA]

Posting Permissions

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