I would like to format a row of cells so that when a word is entered into the cell it automatically becomes a capital.
I need the word to be capitalized so that I can use it in a custom function. The function uses the word from this cell and goes through a bunch of cases in determing how to classify the string.
I think more than one solution is possible and I would greatly appreciate some feed back, I've tried looking into turning all the letters of a string in my VBA code to capitals, or a way to format the cells, so that the string is already capitalized when entered into the VBA code, but I'm still a novice at VBA and unsure on how certain commands work.
here is a sample of my vba code.
Function WeightI(Shape As String, sDim As String, dLenFt As Double) As Double Const pi As Double = 3.14159265358979 Const Ft2In As Double = 12 Const dDen As Double = 0.2835 ' density of steel, pounds per cubic inch
I found this bit of Worksheet_Change code to change the target area to UpperCase. This works fine.
If Not Intersect(Target, Columns(2)) Is Nothing Then Set rng1 = Intersect(Target, Columns(2)) Set rng2 = Intersect(ActiveSheet.UsedRange, rng1) For Each cell In rng2 If cell.Formula "" Then cell.Formula = Format(cell.Formula, ">") End If Next cell End If I could not find anything telling me what the ">" means. I'm assuming that it is a special symbol/wildcard for UCase in VBA.
My question(s), is there a symbol for ProperCase so I can use the same code, just making it change the Target column to Proper? Also is there a list of the special symbols.
In my worksheet there are ranges A3:C37, E3:E37, J3:K37 and P3:P37 that all contain text that I would like to automatically change to proper case once the user leaves any of the referenced cells.
I have tried various codes form this forum and searched for hours on the net for a solution to do this but no matter what I do/try nothing works (for long)
Another forum user did help me out with some code but there was an issue with column C, L & O (which are set as drop down lists) and when the code was put into the workbook these columns stopped working and froze the app.
I have just recently found that I can do case correction with Excel but I am manually having to do it how can I add it to my macro? The function for doing it does not seem straight forward to me on putting in macro I am sure it is simple but just missing some element of it.
I need to have Proper case for columns C, G and H from rows 11 and down.
When I asked this question before, I was looking for a way to automate the exemptions on a UserForm. At that time I realized that automation was not a good choice and went with a CommandButton to turn off the Proper case for that entry. I am now trying to do the same thing on a Worksheet change event using this
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Count > 1 Then Exit Sub If Target.Column < 1 Or Target.Column > 9 Then Exit Sub On Error Goto Errhndl Application.EnableEvents = False If Target.Column = 1 Then Target.Value = Application.Proper(Target.Value) If Target.Column = 2 Then Target.Value = Application.Proper(Target.Value) If Target.Column = 3 Then Target.Value = UCase(Target.Value) If Target.Column = 4 And Target.Value > "" Then Target.Value = UCase(Left(Target.Value, 2)) & "-" & Right(Target.Value, 2) If Target.Column = 8 Then Target.Value = UCase(Target.Value) If Target.Column = 9 Then Target.Value = UCase(Target.Value) Application.EnableEvents = True Exit Sub Errhndl: Application.EnableEvents = True End Sub
My problem is with Target.Column = 1. I need a way to disable the proper case for a single row. I tried to use an additional column (J) and place a x in that row, but I could not figure out how to detect if there was anything in that column for the target row.
I have a number of textboxes into which I enter the surname of individuals ... at present the textboxes are set to store all names in Uppercase. Is there coding to return names beginning Mc... or Mac... ie McClOUD or MacDONALD, in the more recognized format. I am sure this has been included in the forum but could not find it in a search of the site.
Is it possible to modify this code to exclude the first sheet in the workbook which is called Costs?
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) '''''''''''''''''''''''''''''''''''''''''''' 'Forces text to Proper case for the range A14:A39 '''''''''''''''''''''''''''''''''''''''''''' If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub
On Error Resume Next If Not Intersect(Target, Range("A14:A39")) Is Nothing Then Application.EnableEvents = False Target = StrConv(Target, vbProperCase) Application.EnableEvents = True End If On Error Goto 0
End Sub '''''''''''''''''''''''''''''''''''''''''''' 'Forces text to Proper case for the range A14:A39
I am using this macro to ensure that a range of cells appear in Proper Case. However I am encountering a drawback, sometimes I have text which I want in Upper Case but which is changed into Proper Case. I was wondering if there was a way to work around this. Example: Practical W/W appears as W/w or Woodturing (GMC) appears as Woodtrunign(gmc)
Private Sub Worksheet_Change(ByVal Target As Range) '''''''''''''''''''''''''''''''''''''''''''' 'Forces text to Proper case for the range A15:A40 '''''''''''''''''''''''''''''''''''''''''''' If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub
On Error Resume Next If Not Intersect(Target, Range("A15:A40")) Is Nothing Then Application.EnableEvents = False Target = StrConv(Target, vbProperCase) Application.EnableEvents = True End If On Error Goto 0 End Sub
When using the PROPER function, it capitalizes the first letter in a text string and any other letters in text that follow any character other than a letter, and converts all other letters to lowercase.
However, if A1 contains the text "2-cent's worth"; then =PROPER(A1) will return the following result: "2-Cent'S Worth".
Is there a way to prevent the PROPER function from capitalizing the first letter following the apostrophe?
I have a worksheet which is populated from a macro using the following code.
Sheets("Create Sub Contractor").Range("B6:B65").Copy With Sheets("Sub Contractor Information").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0) .PasteSpecial (xlValues), Transpose:=True End With
The problem is that some of what is being copied needs to be Proper and Some Upper, therefore I cant use a paste special option.
What I'd like to be able to do is format the columns in the destination sheet ("Sub Contractor Information") from row 4 down to what ever format they need to be individually as there are some columns that are numbers, some text and numbers........
Is there a way to change the text in a cell to proper apart from 2/3 letter words which I want to keep as upper? Basically can it ignore all words that are 2 or 3 letters long, but change all other words to proper text?
I have a Excel text document that I compile from multiple sources, and if they don't leave a "white space" before a "/", "-", or "(" the Proper Case command does not capitalize the word that immediately follows that symbol.
I use the applicaiton timer but it said time is 5 so what's the problems? Below i want to change to case construct.
Sub GreetMe() If Time < 0.5 Then MsgBox "Good morning!" & " It’s now " & Time, , “The Time” ElseIf Time >= 0.5 And Time < 0.75 Then MsgBox "Good afternoon!" & " It’s now " & Time, , “The Time” Else MsgBox "Good evening!" & " It’s now " & Time, , “The Time” End If End Sub
this is what i did so far but still having problems with it with case construct
Sub GreetMe() Dim morning As Integer Dim afternoon As String Dim goodevening As Integer Select Case morning Case Application.AutoRecover.Time < 0.5.......................
I needed to change the case of entries in range B8:B100 to uppercase, for which I used the VBA I have been using, and it works fine. I now require to also change the case of ranges C8:C100, D8:D100 and E8:E100 to propercase. So, I changed the script to: