Modificar código
Publicado por Patrixia (2 intervenciones) el 03/03/2019 13:54:36
Buenos días.
No tengo conocimientos de VBA, uso excel y me han pasado este código que funciona muy bien, pero quisiera además de que se ejecute en celdas de fecha ,lo hiciera en las de texto indistintamente.
Si cambio la palabra "fecha" por texto también funciona. Pero realizar ambas no sé hacerlo.
Gracias y perdonen, la ignorancia es muy atrevida
No tengo conocimientos de VBA, uso excel y me han pasado este código que funciona muy bien, pero quisiera además de que se ejecute en celdas de fecha ,lo hiciera en las de texto indistintamente.
Si cambio la palabra "fecha" por texto también funciona. Pero realizar ambas no sé hacerlo.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If LCase(Left(Cells(1, Target.Column), 5)) <> "fecha" Then Exit Sub
If IsEmpty(Target) Then Exit Sub Else Cancel = True
Dim fila As Long, col As Long, nuevo As String, antes As String, wf
Set wf = WorksheetFunction: nuevo = Target.Text
With Worksheets("general")
fila = wf.Match(Cells(Target.Row, 1), .Range("a:a"), 0)
col = wf.Match(Cells(1, Target.Column), .Range("1:1"), 0)
With .Cells(fila, col): antes = .Text
If antes <> "" Then _
If MsgBox("actualmente el registro muestra: " & antes & vbCr & _
"deseas cambiarlo por: " & nuevo & " ?", vbYesNo) = vbNo Then Exit Sub
.Value = nuevo
End With: End With: Set wf = Nothing
End Sub
Gracias y perdonen, la ignorancia es muy atrevida
Valora esta pregunta


0