Solo algunas celdas Nombre Propio Modificar con Código ya propuesto

Edmund8

New Member
Joined
Dec 11, 2010
Messages
4
Hola:
He encontrado un código en la web que suple mis necesidades, sin embargo no he podido adaptarlo a mi archivo.

Me encantaría la ayuda de algún experto para lo siguiente: El código automáticamente arregla lo escrito a formato de Nombre Propio, pero lo hace en toda una columna. Yo solo necesito que el evento se de en la celda D4 para dos nombres y D6 para dos apellidos. Lo que me gusta del código es que cobre todas las variantes habidas y por haber referente a nombres y apellidos.
El código es el siguiente:
Option Explicit


Private Sub Worksheet_Change(ByVal Target As Range)


Dim vnp As String: Dim i As Integer: Dim ve As String
Dim viz As Boolean: Dim vde As Boolean: Dim vl As Integer
Dim vle As Integer


With Target
If .Column <> 1 Or .Rows.Count > 1 Then Exit Sub
If .Value = "" Then Exit Sub
End With


vnp = Target: vnp = VBA.StrConv(vnp, vbProperCase)
vnp = VBA.Replace(vnp, " De", " de")
vnp = VBA.Replace(vnp, " La", " la")


For i = 1 To VBA.Len(vnp)
ve = VBA.Mid(vnp, i, 3)
viz = VBA.Mid(ve, 1, 1) = " ": vde = VBA.Mid(ve, 3, 1) = " "
If viz And vde Then vnp = VBA.Replace(vnp, ve, VBA.RTrim(ve) & ". ")
vl = VBA.Len(ve): vle = VBA.InStr(1, ve, " ", vbTextCompare)
If vl = 2 And vle Then vnp = vnp & "."
Next


Target = vnp


End Sub
Gracias mil de antemano, por su ayuda!!!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Estimado Edmund8

Intenta con esto:

Dim celda As Range
For Each celda In Selection
celda.Value = Application.WorksheetFunction.Proper(celda.Value)
Next

Salu2
ColdGeorge
 
Upvote 0
[Quote = ColdGeorge; 3751478] Estimado Edmund8 Intenta estafa ESTO: Salu2 ColdGeorge [/ quote]

Mil gracias ColdGeorge, lo intentaré adaptar y te cuento.
Salu2!!!
 
Upvote 0

Forum statistics

Threads
1,223,943
Messages
6,175,552
Members
452,652
Latest member
eduedu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top