Automatically Change To Proper Case Once The User Leaves Any Of The Referenced Cells
Nov 6, 2008
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 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.
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 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
How can I extend proper() to NOT change "PO Box 333" to "Po Box 333". Ideally, I would like to supply a list of words such as PO and all the 2 letter directionals (NE,NW,SE,SW).
There are also cases such as a last name of MacNamara which should have a capital M and N. Even worse, I see that 3rd becomes 3Rd which is very sad.
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?
Below is the existing code that I'm working with and would like to be able to make the ' name' column either Upper or Proper case on entry. I haven't decided which I'm going to use yet.
Set r = Sheet1.Range("A2:C65536") If Not Intersect(Target, r) Is Nothing Then sTgt = Trim(Target.Value) If sTgt = "" Then Exit Sub
Select Case Target.Column Case NmCol If InStr(sTgt, ",") = 0 Then iSpc = InStrRev(sTgt, " ") Target.Value = Mid(sTgt, iSpc + 1) & ", " & Left(sTgt, iSpc - 1) End If
Some handy code that I can put in a VBA module that will convert all text within a Spreadsheet to Proper or Sentence like this ---> Hello Everyone, Hope You Are All Happy.
I have a worksheet which is populated from a macro using the following code.
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........
I am working on a spreadsheet for work, and have managed to do everything I need to so far but I need to colour specific letter strings, certain colours within a range of cells (each letter string will only appear once on each sheet)
The strings I will be looking for vary depending on data entered so I will need to cell reference them
The strings that need colouring are in cells with other strings that must stay black (They cannot be separated from other strings due to the nature of the grid)
I need some strings red, some green, and some blue.
These changes should also apply to the whole workbook not just one sheet.
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 dorm roster on one sheet and the other sheet is an Alpha Roster. I want it to automatically sort alphabetically (column B) . Any time I change the roster, the Alpha Roster sheet doesn't automatically sort, I have to hilight and re-sort it again.
I updated the file, there are 4 tabs at the bottom. 1st Floor, 2nd Floor, and 3rd Floor. I want to have all the names, room numbers, and phases (ph) in alphabetical order on the Alpha roster tab. And when ever I make changes to one of the Floors, it will automatically update it the Alpha Roster.
I have a worksheet with ever expanding data - rows at the bottom of the data are continually added. I have a simple macro that sorts all of the data according to preset parameters and selects the next blank cell in column A, ready for more data:
Sub Macro5() Range("SortRange").Select Selection.Sort Key1:=Range("SortRange"), Order1:=xlAscending, Header:= _ xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _ xlTopToBottom Do Until ActiveCell.Value = IsEmpty(True) ActiveCell.Offset(1, 0).Activate Loop End Sub
When running the Macro, this leaves all of the cells in the range 'selected' (ie; coloured-over). What do I need to add to the Macro to just select the cell in Column A and remove the highlighting from all the other cells?
I have posted about creating an Excel worksheet which would help determine proper entry into a retirement plan. Another idea that I had entailed setting up a separate worksheet which would return the dates of entry following an employee's date of hire. Therefore, an employee hired on 8/5/2005 would have dates of entry following that stand at 1/1/2006 and 7/1/2006. Then, I had an idea of creating a formula or function to add up the number of hours that the employee had worked.
Setting up a separate worksheet with the number of hours that an employee worked during the initial eligiblity computation period and the subsequent computation periods (separate respective columns for the initial eligibility computation period and then for each subsequent computation period) would help. I would calculate using sum functions.
So, to sketch this out: One sheet would have the employee's DOH
Another worksheet would have the Dates of Entry subsequent to that DOH (e.g. for an employee hired 8/5/2005 the next Dates of Entry entails 1/1/2006, 7/1/2006, and 1/1/2007)
Yet Another Worksheet would sum the total hours that an employee had worked since DOH on a month by month basis (i.e. the total number of hours than employee had worked since his or her DOH up to a certain point on a monthly basis; e.g. an employee hired on 8/5/2005 would have on the sheet the calculation of the hours this employee had worked as of from 8/5/2005 to 9/1/2005, then the next column would have the total the number of hours worked by the employee from 8/5/2005 to 10/1/2005, etc.)
Finally, the worksheet with the DOH information would have a column which would (this would probably entail heavy use of VLOOKUP) snag the information as to how many months and years an employee had worked as of the subsequent Dates of Entry; if the employee had worked 1,000 hours and 12 months as of 1/1/2007, for example, the employee would enter the plan.
To explain the situation further:
The employee must work 1,000 hours during his or her initial eligibility computation period. That starts on the day of the first hour that an employee works for the company. So, an employee hired on August 1, 2005 who worked one hour on that day must 1,000 hours from then till August 1, 2006 to enter the plan as soon as possible. If the employee did not work 1,000 hours during that period, then the eligibility computation period shifts to the plan year. So, if the employee did not work 1,000 hours between August 1, 2005 and August 1, 2006, but did work 1,000 hours between January 1, 2006 and December 31, 2006 (this of course presumes the plan operates on a calendar year)
I am working on a spreadsheet that will be referencing approximately 20-30 separate workbooks which all have identical sheet / column structure and have a consistent file naming convention. ("###-YYYY") Since, this is referencing separate files and not sheets with this workbook, I cannot use INDIRECT. However, I should be able to use index / match referencing provide instructions for users to copy a set of cells down and the globally change the file name. The problem is that the file directory pops up with each instance and the user has to manually select or confirm the file.
There would be approximately 15 cells with a formula similar to this example and would want to change the two instances of "403" to a new 3-digit code, say "444". Then as each year cycles over, we'd want to change all instances of 2014 to 2015.
ABCDEFGHI need to create a macro to perform some conditional formatting1DateDayTypeTimeConfirmed Order No.Site Location2SHEET OVERVIEW301/01/08TuesdayAB4CVertically there will be 366 tables to represent 366 days and Horizontally 10 tables to represent 10 employees,5Dwhich enables the work activities of 10 employees to assigned over the period of a year.6E7AAFIn the type box marked 'A' and 'AA' the user selects from a drop down box a parameter as list below left.8GOn entry of an 'n' in the type box the user can enter data into the 'time','confirmed order','site location' boxes.9HThe idea of having 2 x type boxes is to allow the day to be split into morning and afternoon.10I1102/01/08WednesdayMACRO / VBA FUNCTIONALLITY REQUIRED 1213In the 'type' boxes if the user selects anything other than 'n' then the 4 'site location' boxes and coloured and 14the appropriate text from the list below left is inserted into the 4 associated 'site location' boxes.1516Example:1718Box marked 'A' the user selects 'h'. Boxes marked 'BCDE' and filled with colour and the text holidayBox marked 'AA' the user selects 't'. Boxes marked 'FGHI' and filled with colour and the text trainingType List Entry ParametersWhen the user selects type 'n' after the associated boxes are returned to there blank state (no colour or text)nnormal dayhholidayThe macro/vba would have to respond on everytime a 'type' box changesssickttrainingThere would be 2 x type boxes per day, 366 days a year and for 10 employees. Therefore it would have to monitoruunauthorised absence2 x 366 x 10 (7320) type boxesbbank holidayccompany shutdown
I'm trying to create a list that references an existing data set where I have staff listed month by month and based on today's date, imports only if there is data in that column. I have figured out how to check if the cell is blank or not, but what I want to do now is change the cell that is referenced in the formula based on the date. Here is the format of the spreadsheet I'm working with:
A B C D E F G H
[code].....
In this case, the "Team 1" and "Team 2" and "Team 3" references what team they are on that month. If it is blank, they aren't with the company any longer. The formula I am using is intended to import this data elsewhere, and is formatted like this:
=IF(ISBLANK(B2), "", A2) - My understanding is that this checks to see if B2 has data, and if it does, it inputs the employee name (A3) in that cell.
My ultimate goal is to be able to change the column referenced after the "isblank" calculation based on the date. So if today is April 2013, I want it to check B2, but if it's December 2013, I want the formula to check J2. Is there a way to do this? I don't mind if it's two steps (like if I have to put the date somewhere in the spreadsheet in order to run the calculation), but ultimately it would be the type of thing I could do that would leverage the existing data set so that I don't have to maintain two different spreadsheets of information.
I have been given a spreadsheet that turns whole rows different colours when certain data is entered into a cell. I want to locate the code and use it elsewhere, but cant find it?
I have looked at all of the change related procedures in the drop downs, for the Workbook e.g.
Workbook_SheetChange
but no matter where I cant seem to find any code at all.
Is there a way of exporting every line of code and then open this file in notepad to skim through it?
how I might find the code that is making the rows turn different colours?