Consulting

Results 1 to 4 of 4

Thread: Solved: Excel VBA changing case

  1. #1
    VBAX Regular
    Joined
    Feb 2012
    Posts
    46
    Location

    Solved: Excel VBA changing case

    hi

    i tried a macros for changing case in excel through userform. when im pressing alt+f8 and running the macros it showing the error. Can any one rectify the error.
    Attached Files Attached Files

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You need to use the correct quote characters

    [VBA]Private Sub CancelButton_Click()
    Unload UserForm1
    End Sub

    Private Sub OKButton_Click()

    Application.ScreenUpdating = False

    ' Exit if a range is not selected
    If TypeName(Selection) <> "Range" Then Exit Sub

    ' Upper case
    If OptionUpper Then
    For Each cell In Selection
    If Not cell.HasFormula Then
    cell.Value = StrConv(cell.Value, vbUpperCase)
    End If
    Next cell
    End If

    ' Lower case
    If OptionLower Then
    For Each cell In Selection
    If Not cell.HasFormula Then
    cell.Value = StrConv(cell.Value, vbLowerCase)
    End If
    Next cell
    End If

    'Proper case
    If OptionProper Then
    For Each cell In Selection
    If Not cell.HasFormula Then
    cell.Value = StrConv(cell.Value, bProperCase)
    End If
    Next cell
    End If

    Unload UserForm1
    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
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    or
    [VBA]
    Private Sub OKButton_Click()
    For Each cl In Selection.SpecialCells(2)
    cl.Value = StrConv(cl, IIf(OptionUpper, 1, IIf(OptionLower, 2, 3)))
    Next

    Hide
    End Sub
    [/VBA]

  4. #4
    VBAX Regular
    Joined
    Feb 2012
    Posts
    46
    Location
    thank you . Its working fine

Posting Permissions

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