Results 1 to 20 of 20

Thread: Capitalize first character & spacing - Excel

Threaded View

  1. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Capitalize first character & spacing - Excel

    vbcode Code:
    1. Dim prev As Range   ' range to leave
    2. Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    3. On Error Resume Next
    4. If Not prev Is Nothing Then
    5.     If prev.Column = 1 Then  ' column A
    6.         pos = InStr(prev.Value, ".")
    7.         If pos > 0 Then   ' period in cell
    8.             myarr = Split(prev.Value, ".")  ' divide sentences into arrray
    9.             For i = 0 To UBound(myarr)
    10.                 myarr(i) = Trim(myarr(i))
    11.                 If Len(myarr(i)) > 0 Then myarr(i) = UCase(Left(myarr(i), 1)) & Mid(myarr(i), 2)
    12.             Next
    13.             prev.Value = Join(myarr, ". ")
    14.         End If
    15.     End If
    16. End If
    17. Set prev = Target 'set range for next cell to leave
    18. End Sub
    this code is not working the extra spaces remain as it was....
    Edit: The code works after I remove On Error Resume Next.
    Last edited by VBFnewcomer; Jan 2nd, 2008 at 06:43 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width