Private Sub Worksheet_Change(ByVal Target As Range)
Target.Value = VBA.UCase(Target.Value)
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If((Target.Value & vbNullString) <> vbNullString) Then
Target.Value = UCase(Target.Value)
End If
End Sub
ASKER
ASKER
Private Sub Worksheet_Change(ByVal Target As Range)
If (Target.Cells.Count > 1) Then
'// more than one cell
Dim data() As Variant
data = Target.value
Dim i As Long, j As Long
For i = LBound(data, 1) To UBound(data, 1)
For j = LBound(data, 2) To UBound(data, 2)
If ((data(i, j) & vbNullString) <> vbNullString) Then
data(i, j) = UCase(data(i, j))
End If
Next
Next
Target.value = data
Else
'// only one cell
If ((Target.value & vbNullString) <> vbNullString) Then
Target.value = UCase(Target.value)
End If
End If
End Sub
Side note: This might mess up with formulas.
ASKER
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Target.Value = StrConv(Target.Text, vbProperCase)
End Sub
Would it help to know that only 1 cell will be getting edited at a time?In the case of a single cell, the value property retrieve a single value, wich can be implicitly converted to string.
That code made the workbook even slowerHow many cells are you moving / cut-pasting / copy-pasting / deleting ?
Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.
TRUSTED BY
Open in new window
This does have the downside of also masking other errors, but in something so short and simple, that should not be a concern to obsess over.You don't really *need* the 'On Error Goto 0' at the end, since the full code finishes at that point, but if using in a more elaborate code section, then you would normally want to return error handling to 'standard' as soon as possible.
Alan.