books4cars
Board Regular
- Joined
- Apr 12, 2007
- Messages
- 200
I use the following vb code every day in excel:
Sub prop()
Dim rng1 As Range, c As Range
Set rng1 = Intersect(ActiveSheet.UsedRange, [A:G,I:O,Q:IV])
If Not rng1 Is Nothing Then
For Each c In rng1
c.Value = WorksheetFunction.Proper(c.Value)
Next
End If
[P:P].Replace "non", ""
[P:P].Replace "select...", ""
[e:e,n:n].Replace "P.O.", "PO"
[e:e,n:n].Replace "P. O.", "PO"
[e:e,n:n].Replace "p o", "PO"
[y:y].Replace " ", ""
[y:y].Replace "-", ""
Do
Set c = Cells.Find(" ")
If Not c Is Nothing Then Cells.Replace " ", " "
Loop Until c Is Nothing
For Each c In Intersect(ActiveSheet.UsedRange, [i:i,q:q])
If c Like "*Us*" Then c.Offset(, 1) = Left(c.Offset(, 1), 5)
Next
End Sub
I just added the two lines of code for column Y to remove spaces and hyphens from all cells in that column. When I run the code, the cells that are affected show notation like this 4.85321E+15 instead of a long number. All the cells are formatted to text before I run the code. How can I get just the numbers and not the notation?
Thx
Sub prop()
Dim rng1 As Range, c As Range
Set rng1 = Intersect(ActiveSheet.UsedRange, [A:G,I:O,Q:IV])
If Not rng1 Is Nothing Then
For Each c In rng1
c.Value = WorksheetFunction.Proper(c.Value)
Next
End If
[P:P].Replace "non", ""
[P:P].Replace "select...", ""
[e:e,n:n].Replace "P.O.", "PO"
[e:e,n:n].Replace "P. O.", "PO"
[e:e,n:n].Replace "p o", "PO"
[y:y].Replace " ", ""
[y:y].Replace "-", ""
Do
Set c = Cells.Find(" ")
If Not c Is Nothing Then Cells.Replace " ", " "
Loop Until c Is Nothing
For Each c In Intersect(ActiveSheet.UsedRange, [i:i,q:q])
If c Like "*Us*" Then c.Offset(, 1) = Left(c.Offset(, 1), 5)
Next
End Sub
I just added the two lines of code for column Y to remove spaces and hyphens from all cells in that column. When I run the code, the cells that are affected show notation like this 4.85321E+15 instead of a long number. All the cells are formatted to text before I run the code. How can I get just the numbers and not the notation?
Thx