LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default How to capitilize automatically?

You cannot be using the code originally posted by JLGWhiz. Read the help on
strConv also to see that values of Proper, PCase, etc are not valid.

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
If Not Application.Intersect(Target, Range("C9:C47")) Is Nothing Then
' Target(1).Value = UCase(Target(1).Value)
Target(1).Value = StrConv(Target(1).Value, vbProperCase)
End If
Application.EnableEvents = True

End Sub

NickHK

wrote in message
oups.com...
On Apr 24, 8:23 am, Susan wrote:
just as a quickie test this worked for me..........
====================
Sub change_case()

Dim ws As Worksheet
Dim c As Range
Dim s As String

Set ws = ActiveSheet
Set c = ws.Range("e5")
s = "mary smith"

c = s
c.Value = StrConv(c.Value, vbProperCase)

End Sub
================
result was "Mary Smith".

(WS is short for worksheet, so JLGWhiz was talking about your
worksheet_change event. the command line is the line that calls
another macro.)

what happens when you change

If Not Application.Intersect(Target, Range("C9:C47")) Is Nothing Then
Target(1).Value = UCase(Target(1).Value)


to
If Not Application.Intersect(Target, Range("C9:C47")) Is Nothing Then
Target(1).Value = ProperCase(Target(1).Value)

does that work?
:)
susan

On Apr 23, 11:51 pm, wrote:

On Apr 23, 10:14 pm, JLGWhiz
wrote:


This will get you started:


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("C:C"), Target) "" Then
Range("C3").Value = StrConv(Range("C3").Value, 3)
End If
End Sub


I did not see the specific macro that you referenced in your WS

change code,
but if you substitute it on the command line of the if statement

above and
you still don't get the results you want, then it will be that macro

that is
the problem. The one above will execute, as is, and will change

whatever is
in Range("C3") of that worksheet to ProperCase.


I'm sorry I'm still new so I'm not sure what you mean by "WS" change
code and I have absolutely no idea what the command line is on the if
statement. I did come close to what I'm trying to achieve though. On
another site I found a code for proper for a macro and it also has a
change code for Upper to which it says all you have to do is change it
to proper if that's what you want like it previously described. The
trouble is I can't get it to work. It looks like it's looking for
something different than just entering "vbProperCase".


This is my macro and my only macro now:


Sub Proper_Case()
Dim Rng As Range
For Each Rng In Selection.Cells
If Rng.HasFormula = False Then
Rng.Value = StrConv(Rng.Value, vbProperCase)
End If
Next Rng
End Sub


This is my change code and it is entered on sheet 1:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("C9:C47")) Is Nothing Then
Target(1).Value = UCase(Target(1).Value)
End If
Application.EnableEvents = True
End Sub


This works beautifully to change it to upper case but I can't figure
out how to do proper case instead. I've tried changing UCase to
vbproper case, proper, propercase, none worked. I also tried replacing
the whole line with rng.value line from the macro. Obviously I'm not
doing something right, I just don't know what.


Ideas?


Charles


Okay, I'm gonna try this for the third time. Dang thing keeps losing
my post.

I've tried doing that as well as using Proper, vbProperCase, PCase and
none worked. At least I don't think so. I may have been doing it wrong
somehow. After I tried using those and they didn't work I would change
it back to UCase which worked before, but when I change it back, it
wouldn't.

Charles



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically insert time in excel but not automatically updated NeueN Excel Worksheet Functions 4 December 25th 08 07:29 AM
How to capitilize automatically? [email protected] Excel Discussion (Misc queries) 0 April 23rd 07 11:01 PM
St automatically changes to So lkaneft Excel Discussion (Misc queries) 2 June 30th 06 03:43 PM
Capitilize first letter Craig Excel Worksheet Functions 8 January 31st 05 03:21 AM
Automatically add new row vwhungsuriya Excel Programming 1 May 26th 04 01:58 PM


All times are GMT +1. The time now is 09:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"