본문 바로가기
Office

[Excel] vba cell 현재 위치 알아내기

by 청운추월 2023. 5. 2.
반응형
Excel VBA로 현재 위치를 알아내는 코드입니다. 
활성화된 Cell 위치나  영역설정시의 위치 및 영역에서의 row,column 개수를 알아낼 수 있습니다. 
Function position()
    '현재 활성화된 Cell 위치
    Debug.Print ActiveCell.Row
    Debug.Print ActiveCell.Column
 
    '현재 지정된 영역의 Cell 위치
    Debug.Print Selection.Cells.Row
    Debug.Print Selection.Cells.Column
    
    '현재 지정된 영역의 가로세로 개수
    Debug.Print Selection.Cells.Rows.Count
    Debug.Print Selection.Cells.Columns.Count
    
    
End Function