又学了一招,Union方法,嘿嘿。
Option Explicit
'1 表示一个单元格(a1)
Sub s()
Range("a1").Select
Cells(1, 1).Select
Range("A" & 1).Select
Cells(1, "A").Select
Cells(1).Select
[a1].Select
End Sub
'2 表示相邻单元格区域
Sub d() '选取单元格a1:c5
' Range("a1:c5").Select
' Range("A1", "C5").Select
' Range(Cells(1, 1), Cells(5, 3)).Select
'Range("a1:a10").Offset(0, 1).Select
Range("a1").Resize(5, 3).Select
End Sub
'3 表示不相邻的单元格区域
Sub d1()
Range("a1,c1:f4,a7").Select
'Union(Range("a1"), Range("c1:f4"), Range("a7")).Select
End Sub
Sub dd() 'union示例
Dim rg As Range, x As Integer
For x = 2 To 10 Step 2
If x = 2 Then Set rg = Cells(x, 1)
Set rg = Union(rg, Cells(x, 1))
Next x
rg.Select
End Sub
'4 表示行
Sub h()
'Rows(1).Select
'Rows("3:7").Select
'Range("1:2,4:5").Select
Range("c4:f5").EntireRow.Select
End Sub
'5 表示列
Sub L()
' Columns(1).Select
' Columns("A:B").Select
' Range("A:B,D:E").Select
Range("c4:f5").EntireColumn.Select '选取c4:f5所在的行
End Sub
'6 重置坐标下的单元格表示方法
Sub cc()
Range("b2").Range("a1") = 100
End Sub
'7 表示正在选取的单元格区域
Sub d2()
Selection.Value = 100
End Sub