|
'with 语句 ,当对某个对象执行一系列的语句时,不用重复指出对象的名称。
Sub with语句1()
a = Range("a1").Address
b = Range("a1").Parent.Name
Range("a1") = "1234"
End Sub
Sub with语句2()
With Range("a1")
a = .Address
b = .Parent.Name
.Value = "1234"
End With
End Sub
Sub with嵌套1()
Range("a1").Value = "Who am i ?"
Range("a1").Parent.Name = "Hello World"
Range("a1").Font.Size = 20
Range("a1").Font.Bold = True
End Sub
Sub with嵌套2()
With Range("a1")
.Value = "Who am i ?"
.Parent.Name = "Hello World"
With .Font
.Size = 20
.Bold = True
End With
End With
End Sub
|
|