bomberman411
Board Regular
- Joined
- Oct 23, 2007
- Messages
- 169
Hi all,
I need a simple solution to make a mass-change in about 4000 cells.
My spreadsheet has over 4000 lines of data. One of my columns is for employee numbers. It's a 6 digit number (like 106500). The 10 in front of the number was tagged on a while back by our human-resources departement, it used to be a 4 digit number. We had to correct all the data a while back and add a "10" in front of each number. Some have a "20" tagged in front of it, others a "40"... basically this means that the real number to keep is the four last digits.
I need to take out the second digit in each number, in each cell. That digit should be "0" for all those employee numbers. So "106500" becomes "16500"... "409400" should become "49400"....
My data, the employee numbers, are in column "D" and starts at row "10".
I already have a "Worksheet_Change" event to change case to "ProPeR" for all the employee names, and I would like to use that same code to check if the employee number is 6 digits long or 5. If it's 6, it should remove the 2nd digit. If it's 5 then it should be left untouched.
Here's the code I already have:
I appreciate all the help I can get on this one... even though I have backups, I can't make any mistakes on this one, the file is too important.
I need a simple solution to make a mass-change in about 4000 cells.
My spreadsheet has over 4000 lines of data. One of my columns is for employee numbers. It's a 6 digit number (like 106500). The 10 in front of the number was tagged on a while back by our human-resources departement, it used to be a 4 digit number. We had to correct all the data a while back and add a "10" in front of each number. Some have a "20" tagged in front of it, others a "40"... basically this means that the real number to keep is the four last digits.
I need to take out the second digit in each number, in each cell. That digit should be "0" for all those employee numbers. So "106500" becomes "16500"... "409400" should become "49400"....
My data, the employee numbers, are in column "D" and starts at row "10".
I already have a "Worksheet_Change" event to change case to "ProPeR" for all the employee names, and I would like to use that same code to check if the employee number is 6 digits long or 5. If it's 6, it should remove the 2nd digit. If it's 5 then it should be left untouched.
Here's the code I already have:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngProper As Range, Cell As Range
Set rngProper = Intersect(Range("B6:B1000,C6:C1000"), Target)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not rngProper Is Nothing Then
For Each Cell In rngProper
Cell.Value = WorksheetFunction.Proper(Cell.Value)
Next Cell
End If
ws_exit:
Application.EnableEvents = True
End Sub
I appreciate all the help I can get on this one... even though I have backups, I can't make any mistakes on this one, the file is too important.