VBA Conversión instantánea de letras a mayúsculas al llenar la celda de Excel
Frecuentes
Visto 4,353 equipos
0
I am looking for a macro that will automáticamente be activated upon event.
If someone inserts a text value or a value that has text on cell A1
once he presses enter and the cell has been populated if there is somewhere a minúscula letter it will convert it to mayúscula.
However the catch is that it must be automatically without having to fire-up the macro yourself.
3 Respuestas
4
Introduzca la siguiente macro de eventos en el área de código de la hoja de trabajo:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim A1 As Range
Set A1 = Range("A1")
If Not Intersect(Target, A1) Is Nothing Then
Application.EnableEvents = False
Target.Value = UCase(Target.Value)
Application.EnableEvents = True
End If
End Sub
Debido a que es un código de hoja de trabajo, es muy fácil de instalar y automático de usar:
- haga clic derecho en el nombre de la pestaña cerca de la parte inferior de la ventana de Excel
- seleccione Ver código - esto abre una ventana VBE
- pegue las cosas y cierre la ventana de VBE
Si tiene alguna duda, primero inténtelo en una hoja de trabajo de prueba.
Si guarda el libro de trabajo, la macro se guardará con él. Si está utilizando una versión de Excel posterior a 2003, debe guardar el archivo como .xlsm en lugar de .xlsx
Para eliminar la macro:
- abre las ventanas de VBE como arriba
- borrar el código
- cerrar la ventana VBE
Para obtener más información sobre las macros en general, consulte:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
y
http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx
Para obtener más información sobre macros de eventos (código de hoja de trabajo), consulte:
http://www.mvps.org/dmcritchie/excel/event.htm
¡Las macros deben estar habilitadas para que esto funcione!
contestado el 24 de mayo de 14 a las 16:05
1
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Target.Value = UCase(Target.Value)
End If
End Sub
Tested only in worksheet code.
contestado el 24 de mayo de 14 a las 16:05
Try without .Value if it behaves strangely - rex
well i put lowercase characters in Cell A1
at Worksheet 1 but they are not automatically converted to uppercase. I've put this code in a separate module - Codo
your code seems right however once i enter a value in lowercase like bdf it is not converted to uppercase automatically upon pressing enter and populating the cell i don't know why... - Codo
changed the code, the address has the $s in it by default - rex
Godbless it works i will mark your question as correct when timer allows. Sorry for the basicness of the questions but my skills in VBA
are a little rusty...:P - Codo
-1
I asked this on another thread, and was able to do this quite simply
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Column = 7 Then Target = UCase(Target)
Application.EnableEvents = True
End Sub
If you wanted to do it to all cells, and not just the last cell if it's in a particular column, you can remove the "If" through "then" segment
contestado el 09 de mayo de 22 a las 21:05
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas vba excel excel-2010 or haz tu propia pregunta.
Look up events and in particular the Change Event: Occurs when cells on the worksheet are changed by the user or by an external link. I think that is what you want. - Tony Dallimore