Private Sub Worksheet_SelectionChange(ByVal Target As Range) '工作表选定区域发生改变时执行
Dim b1 As Boolean
Dim a, b, c, d As Variant
Dim I, J As Integer
Set myDocument = ThisWorkbook.Worksheets("Sheet1") '‘Sheet1’为当前工作簿
For I = 2 To 1000 '循环2-1000次,即:D2单元格以下大小写改变到1000行
a = myDocument.Cells(I, 1) '将单元格赋值给a
b = myDocument.Cells(I, 2)
c = myDocument.Cells(I, 3)
d = myDocument.Cells(I, 4)
b1 = WorksheetFunction.And(d <> "") '条件:当D列单元不为空时
If b1 = True Then '当单元格输入内容时,则执行自动大小写改变
myDocument.Cells(I, 4) = UCase(myDocument.Cells(I, 4)) '引用当前单元格内容,4为第几列的意思(D列)
End If
Next
End Sub
Sub 大小写改变()
End Sub
温馨提示:内容为网友见解,仅供参考