???? ID: 291308 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

???? ???????

Microsoft ???????????? ?????? ???? ?????? ?? ??? ?????? ?? ????, ?? ?? ?????? ?? ???? ???? ??? ?? ????? ??, ????? ???? ?? ???, ??????? ?????? ?? ?????? ?? ???? ????? ???????? ?? ??? ????????? ?? ????? ???? ??? ?? ???? ????? ?? ?? ?? ????? ???????????? ???? ?? ??? ?? ???????????? ???? ?? ????? ????? ?? ??????????? ???? ???? ?? ??? ????? ???? ???? ?? ?? ??? ?????? ???? Microsoft ?????????????????? ???????????????????????? ?????? ??????????????? ??????????????????????????? ?????? ???????????????????????????????????? ?????? ?????????????????? ????????? ?????????????????? ?????? ???????????? ?????????, ??????????????? ?????? ?????? ???????????????????????? ?????? ???????????? ????????????????????? ?????????????????????????????? ?????? ???????????? ???????????? ?????? ????????? ???????????????????????????????????? ????????????????????????????????????????????? ??????????????? ?????????????????????????????? ?????????????????? ???????????? ?????? ????????? ????????????????????? ???????????? ????????????????????? ?? ???? ??? ?????? ????? ?????? ??? ???????? Visual Basic ??????? ?? ????? ?????
   Method             Arguments
   ------------------------------------------
   Activate           none
   Cells              rowIndex, columnIndex
   Application.Goto   reference, scroll
   Offset             rowOffset, columnOffset
   Range              cell1
                      cell1, cell2
   Resize             rowSize, columnSize
   Select             none
   Sheets             index (or sheetName)
   Workbooks          index (or bookName)
   End                direction
   CurrentRegion      none
				
?? ???? ??? ?????? ????? ?????? ??? ??? ?? ????? ?????
   Property         Use
   ---------------------------------------------------------------------
   ActiveSheet      to specify the active sheet
   ActiveWorkbook   to specify the active workbook
   Columns.Count    to count the number of columns in the specified item
   Rows.Count       to count the number of rows in the specified item
   Selection        to refer to the currently selected range
				

1: ?????? ?????????? ?? ???? ???? ?? ??? ???? ?? ??? ????

?????? ?????????? ?? ???? D5 ?? ??? ???? ?? ???, ?? ?? ?? ????? ?????? ?? ????? ?? ???? ???:
ActiveSheet.Cells(5, 4).Select
				
- ?? -
ActiveSheet.Range("D5").Select
				

2: ??? ????????????? ??? ???? ???? ?????????? ?? ???? ???? ?? ??? ???? ?? ??? ????

??? ????????????? ??? ???? ???? ?????????? ?? ???? E6 ?? ??? ???? ?? ???, ?? ?? ?? ????? ?????? ?? ????? ?? ???? ???:
Application.Goto ActiveWorkbook.Sheets("Sheet2").Cells(6, 5)
				
   -or-
				
Application.Goto (ActiveWorkbook.Sheets("Sheet2").Range("E6"))
				
??, ?? ?????????? ?? ?????? ?? ???? ???, ?? ??? ???? ?? ??? ???? ?? ??? ???? 1 ??? ?? ????? ????:
Sheets("Sheet2").Activate
ActiveSheet.Cells(6, 5).Select
				

3: ???? ????? ????????????? ??? ??? ?????????? ?? ???? ???? ?? ??? ???? ???? ?? ??? ????

???? ???? ????????????? ??? ??? ?????????? ?? ???? F7 ?? ??? ???? ?? ???, ?? ?? ?? ????? ?????? ?? ????? ?? ???? ???:
Application.Goto Workbooks("BOOK2.XLS").Sheets("Sheet1").Cells(7, 6)
				
- ?? -
Application.Goto Workbooks("BOOK2.XLS").Sheets("Sheet1").Range("F7")
				
??, ?? ?????????? ?? ?????? ?? ???? ???, ?? ??? ???? ?? ??? ???? ?? ??? ???? 1 ??? ?? ????? ????:
Workbooks("BOOK2.XLS").Sheets("Sheet1").Activate
ActiveSheet.Cells(7, 6).Select
				

4: ???? ?????? ?? ?????? ?? ?????? ?????????? ?? ??? ???? ?? ??? ????

C2:D10 ?????? ?????????? ?? ?????? ?? ??? ???? ?? ???, ?? ????? ?????? ?? ??? ?? ????? ?? ???? ???:
ActiveSheet.Range(Cells(2, 3), Cells(10, 4)).Select
				
ActiveSheet.Range("C2:D10").Select
				
ActiveSheet.Range("C2", "D10").Select
				

5: ??? ????????????? ??? ??? ?????? ?? ?????? ?? ???? ???? ?????????? ?? ??? ???? ?? ??? ????

??? ????????????? ??? ???? ???? ?????????? ?? D3:E11 ?? ?????? ?? ??? ???? ?? ???, ?? ?? ?? ????? ?????? ?? ????? ?? ???? ???:
Application.Goto ActiveWorkbook.Sheets("Sheet3").Range("D3:E11")
				
Application.Goto ActiveWorkbook.Sheets("Sheet3").Range("D3", "E11")
				
??, ?? ?????????? ?? ?????? ?? ???? ???, ?? ?? ?? ?????? ?? ??? ???? ?? ??? ???? 4 ??? ?? ????? ????:
Sheets("Sheet3").Activate
ActiveSheet.Range(Cells(3, 4), Cells(11, 5)).Select
				

6: ???? ????? ????????????? ??? ??? ?????? ?? ???? ???? ?????????? ?? ??? ???? ?? ??? ????

???? ???? ????????????? ??? ???? ?????????? ?? E4:F12 ?? ?????? ?? ??? ???? ???? ?? ???, ?? ?? ?? ????? ?????? ?? ????? ?? ???? ???:
Application.Goto Workbooks("BOOK2.XLS").Sheets("Sheet1").Range("E4:F12")
				
Application.Goto _
      Workbooks("BOOK2.XLS").Sheets("Sheet1").Range("E4", "F12")
				
??, ?? ?????????? ?? ?????? ?? ???? ???, ?? ?? ?? ?????? ?? ??? ???? ?? ??? ???? 4 ??? ?? ????? ????:
Workbooks("BOOK2.XLS").Sheets("Sheet1").Activate
   ActiveSheet.Range(Cells(4, 5), Cells(12, 6)).Select
				

7: ?????? ?????????? ?? ??? ???????? ?????? ?? ??? ???? ?? ??? ????

?????? ?????????? ?? ???????? ?????? "???????" ?? ??? ???? ?? ???, ?? ?? ?? ????? ?????? ?? ????? ?? ???? ???:
Range("Test").Select
				
Application.Goto "Test"
				

8: ??? ????????????? ??? ???? ???? ?????????? ?? ??? ???????? ?????? ?? ??? ???? ?? ??? ????

??? ????????????? ??? ???? ???? ?????????? ?? ???????? ?????? "???????" ?? ??? ???? ?? ???, ?? ????? ?????? ?? ????? ?? ???? ???:
Application.Goto Sheets("Sheet1").Range("Test")
				
??, ?? ?????????? ?? ?????? ?? ???? ???, ?? ?? ???????? ?????? ?? ??? ???? ?? ??? ???? 7 ??? ?? ????? ????:
Sheets("Sheet1").Activate
Range("Test").Select
				

9: ???? ????? ????????????? ??? ??? ?????????? ?? ??? ???????? ?????? ?? ??? ???? ?? ??? ????

???? ???? ????????????? ??? ??? ?????????? ?? ???????? ?????? "???????" ?? ??? ???? ?? ???, ?? ????? ?????? ?? ????? ?? ???? ???:
Application.Goto _
   Workbooks("BOOK2.XLS").Sheets("Sheet2").Range("Test")
				
??, ?? ?????????? ?? ?????? ?? ???? ???, ?? ?? ???????? ?????? ?? ??? ???? ?? ??? ???? 7 ??? ?? ????? ????:
Workbooks("BOOK2.XLS").Sheets("Sheet2").Activate
Range("Test").Select
				

10: ?? ???? ??????? ???? ?? ??? ?????? ???? ?? ??? ???? ?? ??? ????

???? ??? ?? ???? ????????? ?? ??? ??????? ?? ?????? ???? ?? ???? ?? ?? ?? ???? ???? ?? ??? ???? ?? ???, ?? ????? ?????? ?? ????? ?? ???? ???:
ActiveCell.Offset(5, -4).Select
				
??????? ?? ????????? ?? ??? ??????? ?? ?????? ???? ?? ???? ?? ???? ???? ?? ??? ???? ?? ???, ?? ????? ?????? ?? ????? ?? ???? ???:
ActiveCell.Offset(-2, 3).Select
				
??? ???? "??? ??????????." ?? ?? ???? ???? ?? ??? ???? ?? ?????? ???? ???, ?? ?????? ?? ????? ??? ????? ???? ?? ?? ?????? ???? ??? ??? ?????? ???? ??? ????? ??????? ?????? ???? ??? ????? A ?? D ??, ?? ?? ??? ????? ?? ???? ?????? ?????? ???????

11: ????? ?? ?? ???? ??????? ?? ??? ???? ?? ??? ???? (???? ??????) ????

???? ??? ?? ???? ????????? ?? ??? ??????? ?? C7 ???? ?? ???? ?? ???? ???? ?? ??? ???? ?? ???, ?? ?? ?? ????? ?????? ?? ????? ?? ???? ???:
ActiveSheet.Cells(7, 3).Offset(5, 4).Select
				
ActiveSheet.Range("C7").Offset(5, 4).Select
				

12: ???? ???? ?? ?????? ?????? ?? ???? ????????? ?????? ?? ????? ?? ??? ????

???? ?? ???????? ?????? "???????" ???? ???? ??, ????? ?? shifted ??? ????????? ???? ?? ?? ??? ????? ???? ?? ?? ???? ?????? ?? ??? ???? ?? ???, ?? ????? ?????? ?? ????? ?? ???? ???:
ActiveSheet.Range("Test").Offset(4, 3).Select
				
??? ???? ???? ?? ???????? ?????? ?? (???? ??????) ??????????, ???? ?? ?????????? ?????? ????, ?? ???? ??? ????? ?????? ????? ?????? ?? ??? ????:
Sheets("Sheet3").Activate
ActiveSheet.Range("Test").Offset(4, 3).Select
				

13: ???? ????????? ?????? ?? ??? ???? ?? ??? ?? ???? ????? ?? ??? ????

???????? ?????? "???????" ?? ??? ????, ?? ??? ?? ???? ????????? ??? ??????? ???? ?? ???, ?? ????? ?????? ?? ????? ?? ???? ???:
Range("Database").Select
Selection.Resize(Selection.Rows.Count + 5, _
   Selection.Columns.Count).Select
				

14: ???? ????????? ?????? ?? ??? ????, ??? ??????, ?? ??? ??? ?? ???? ????? ?? ??? ????

???? ?? ?? ?????? ??? ????????? ?? ???????? ?????? "???????" ?? ???? ?? ??? ??????? ?? ??? ???? ?? ?? ????????? ?? ????? ?? ???????? ?????? ?? ???? ????? ???? ?? ???, ?? ????? ?????? ?? ????? ?? ???? ???:
Range("Database").Select
Selection.Offset(4, 3).Resize(Selection.Rows.Count + 2, _
   Selection.Columns.Count + 1).Select
				

15: ??? ?? ?? ?? ???? ?? ??? ???? ?? ??? ???? ????????? ?????????

??? (??????, ??????? ???????) ?? ?? ???????? ????????? "???????" ?? "?????" ?? ??? ???? ?? ???, ?? ????? ?????? ?? ????? ?? ???? ???:
Application.Union(Range("Test"), Range("Sample")).Select
				
????? ??? ?? ????? ????????? ?? ????? ???? ?? ??? ?? ?????? ?? ??? ?? ?? ?????????? ???? ?????? ?? ?? ??? ???? ?? ?????? ?????? ????? ?? ??? ???? ???? ??? ?????? ?? ???, ?? ?????? ???? ????? ??
Set y = Application.Union(Range("Sheet1!A1:B2"), Range("Sheet1!C3:D4"))
				
????? ?? ??????
Set y = Application.Union(Range("Sheet1!A1:B2"), Range("Sheet2!C3:D4"))
				
?????? ????? ???? ??:
????????? ???? ?? ?????? ?????? ???? ???

16: ?? ?? ???? ?? ???????? ????? ?? ??? ???? ?? ??? ???? ????????? ?????????

?? ???????? ????????? "???????" ?? "?????" ?? ???????? ????? ?? ??? ???? ?? ???, ?? ????? ?????? ?? ????? ?? ???? ???:
Application.Intersect(Range("Test"), Range("Sample")).Select
				
????? ??? ?? ????? ????????? ?? ????? ???? ?? ??? ?? ?????? ?? ??? ?? ?? ?????????? ???? ??????



???? ?? ????? ????? ??? ???? ?? ??? ?? ???? ??? 17 21 ?????? ?????? ???????? ?????? ??? ????? ???? ??? ???? ??????? ?? ?????? ?? ?? ?????? ????? ???
   A1: Name    B1: Sales    C1: Quantity
   A2: a       B2: $10      C2: 5
   A3: b       B3:          C3: 10
   A4: c       B4: $10      C4: 5
   A5:         B5:          C5:
   A6: Total   B6: $20      C6: 20
				

17: ?????? ???? ?? ???? ????? ?? ????? ???? ?? ??? ???? ?? ??? ????

???? ??????? ????? ??? ????? ???? ?? ??? ???? ?? ???, ????? ?????? ?? ????? ????:
ActiveSheet.Range("a1").End(xlDown).Select
				
?? ??? ????? ?????? ?? ??? ????? ???? ???? ??, ?? A4 ???? ?? ??? ???? ??????

18: ?? ?????? ???? ?? ???? ????? ?? ???? ????? ???? ?? ??? ???? ?? ??? ????

???? ???? ?????? ?????? ?? ?? ?????? ?? ??? ???? ?? ???, ????? ?????? ?? ????? ????:
ActiveSheet.Range("a1").End(xlDown).Offset(1,0).Select
				
?? ??? ????? ?????? ?? ??? ????? ???? ???? ??, ?? A5 ???? ?? ??? ???? ??????

19: ???? ????? ??? ?????? ?????? ?? ?? ???? ?????? ?? ??? ???? ?? ??? ????

???? ????? ??? ?????? ?????? ?? ?? ?????? ?? ??? ???? ?? ???, ????? ?????? ??? ?? ?? ?? ????? ????:
ActiveSheet.Range("a1", ActiveSheet.Range("a1").End(xlDown)).Select
				
   -or-
				
ActiveSheet.Range("a1:" & ActiveSheet.Range("a1"). _
      End(xlDown).Address).Select
				
?? ??? ????? ?????? ?? ??? ????? ???? ???? ??, ?? ???? A1 A4 ?? ?????? ?? ??? ???? ??????

20: ???? ????? ??? ?????? ?? ???? ?????? ?? ???-?????? ??? ???? ?? ??? ????

???-?????? ?????? ?? ???? ?????? ?? ??? ???? ?? ???, ????? ?????? ??? ?? ?? ?? ????? ????:
ActiveSheet.Range("a1",ActiveSheet.Range("a65536").End(xlUp)).Select
				
   -or-
				
ActiveSheet.Range("a1:" & ActiveSheet.Range("a65536"). _
   End(xlUp).Address).Select
				
?? ??? ????? ?????? ?? ??? ????? ???? ???? ??, ?? ??? A6 ?? ?????? ?? ???? A1 ?? ??? ??????

21: ???? ??????? ?????? ?? ?????? ?? ??? ???? ?? ??? ????

???? ???? ?? ??-??? ?????? ?? ???? ??????? ?????? ?? ??? ???? ?? ???, CurrentRegion ???? ?? ????? ????? CurrentRegion ???? ?????? ????? ?????? ???? ??????? ????? ????????? ?? ????? ??????? ?? ???? ?? ????? ?? ?????? bounded ??? CurrentRegion ?????? ?? ????? ???? ?? ??? ???? ?? ?? ?????? ?????????? ??:
ActiveSheet.Range("a1").CurrentRegion.Select
				
?? ??? C4 ?? ?????? ?? ???? A1 ?? ??? ??????? ???? ?????? ?????? ?? ?????? ?? ??? ???? ?? ??? ???? ???????? ???:
ActiveSheet.Range("a1", _
   ActiveSheet.Range("a1").End(xlDown).End(xlToRight)).Select
				
   -or-
				
ActiveSheet.Range("a1:" & _
   ActiveSheet.Range("a1").End(xlDown).End(xlToRight).Address).Select
				
??? ???????????? ???, ?? C6 ?? ?????? ?? ???? A1 ?? ??? ???? ?? ??? ?? ???? ???? ?? ?????? ???, CurrentRegion ???? ????? ?????? ?? ???? ?? ?????? 5 ??? ???? ?????? ????? ?????? ??? ?????? ?? ??? ??????:
lastCol = ActiveSheet.Range("a1").End(xlToRight).Column
lastRow = ActiveSheet.Cells(65536, lastCol).End(xlUp).Row
ActiveSheet.Range("a1", ActiveSheet.Cells(lastRow, lastCol)).Select
				
    -or-
				
lastCol = ActiveSheet.Range("a1").End(xlToRight).Column
lastRow = ActiveSheet.Cells(65536, lastCol).End(xlUp).Row
ActiveSheet.Range("a1:" & _
   ActiveSheet.Cells(lastRow, lastCol).Address).Select
				

22. ????? ????? ?? ?????? ???-?????? ????? ?? ??? ???? ?? ??? ????

????? ????? ?? ?????? ???-?????? ????? ?? ??? ???? ?? ???, ????? ????? ?????? ?? ?????? ?????? ?? ????? ????:
   A1: 1  B1: 1  C1: 1  D1: 1
   A2: 2  B2: 2  C2: 2  D2: 2
   A3: 3  B3: 3  C3: 3  D3: 3
   A4:    B4: 4  C4: 4  D4: 4
   A5:    B5: 5  C5: 5  D5:
   A6:    B6:    C6: 6  D6:
				
StartRange = "A1"
EndRange = "C1"
Set a = Range(StartRange, Range(StartRange).End(xlDown))
Set b = Range(EndRange, Range(EndRange).End(xlDown))
Union(a,b).Select
				
?? ??? ????? ?????? ?? ??? ????? ???? ???? ??, ?? A1:A3 ?? C1:C6 ?? ???? ?? ??? ???? ??????

?????? ?? ???

  • Aspecific ????? ??? ???? ??, ?? ??? implied ?? ??????? ??? ActiveSheet ??? ????????:, ???? ???? ?? ???? ???? ?????? ?? ???, ?? ????
    ActiveSheet.Range("D5").Select
    						
    ?? ?? ????? ?? ???? ???:
    Range("D5").Select
    						
  • ActiveWorkbook ??? ?? ????? ?? ????? ??? ?? ?? ???? ???? ?????? ????????????? ?? ???? ?? ??????? workbookis, implied ???
  • ?? ?? Application.Goto ???? ?? ????? ????, ?? ?? ????? ?? ????????? ?????? ??, ?? ?????? ?????? ??? ?? ???? ??????? ?? ????? ???? ????? ??? (???? ??????) ??????????, ?? ??? ?? ????? ???????? ????? ???? ?????? ?????? ?? ???:
    Application.Goto Sheets("Sheet1").Range( _
          Sheets("Sheet1").Range(Sheets("Sheet1").Cells(2, 3), _
          Sheets("Sheet1").Cells(4, 5)))
    					
  • ?????? ????? (?????? ?? ???, namedrange "???????") ??? ???? ???? ?? ???, ?? ???? ??? ???????? ????? ??? ?? ?? ?? ?? ????? ?? ???? ???? Forexample, ?? ????
    ActiveWorkbook.Sheets("Sheet1").Activate
    						
    ?? ?? ????? ?? ???? ???
    ActiveWorkbook.Sheets(myVar).Activate
    						
    ???? myVar ?? ??? "?????1" ???

??????


?? ???? ??? ????? ??? ?? ????? ???? ???? ?? ???? ??? ???? ??????? ?? ??? Microsoft ?????? ??? ??? ???? ????? ?? ??? ????? ???? ?????? ?? ????? ????:
290140 ???????? ????? ?? Office XP ??????????? ?? ??? ????? ??? ?? ????? ?? ??? ????

???

???? ID: 291308 - ????? ???????: 18 ?????? 2013 - ??????: 4.0
???? ???? ???? ??:
  • Microsoft Office Excel 2003
  • Microsoft Office Excel 2007
  • Microsoft Excel 2010
??????: 
kbautomation kbmacro kbdtacode kbhowto kbprogramming kbmt KB291308 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:291308

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com