Skip to content
컴퓨터잡담
2011.10.17 19:07

Excel VBA) 자주쓰는 함수모음

조회 수 21649 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

Excel VBA) 자주쓰는 함수모음

'현재 줄 내용 다음줄에 추가

'선택된 셀의 행 번호를 취득

thisRow = ActiveCell.Row

'복사하고 싶은 대상을 문자열로 편집

address1 = "A" + CStr(thisRow) + ":G" + CStr(thisRow)

'삽입될 범위

address3 = "A" + CStr(thisRow + 1) + ":G" + CStr(thisRow + 1)

Range(address1).Select


'현재 줄 내용 다음줄에 추가

Range("A1").Select

Selection.End(xlDown).Select

ActiveCell.Offset(1, 0).Select





'마지막 행수(비어있는 셀은 포함하지 않음) 예) LValue(B1)

Function LValue(aRange As Range)

     LValue = Range(aRange.Address).End(xlDown).Value

End Function


'값이 있는 마지막 셀의 위치

xlSheet.OlePropertyGet("UsedRange").OlePropertyGet("Rows").OlePropertyGet("Count"); 

xlSheet.OlePropertyGet("UsedRange").OlePropertyGet("Columns").OlePropertyGet("Count"); 

cntrow = WorkSheets(1).UsedRange.Rows.Count

cntcol = WorkSheets(1).UsedRange.Columns.Count


'다음은 특정 행이나 열의 마지막 셀의 위치값을 반환한다.

'두번째 열의 마지막 행 까지의 셀개수를 가져온다

cntRow2 = WorkSheets(1).Cells(Rows.Count, 2).End(xlUp).Row

'두번째 행의 마지막 열 까지의 셀개수를 가져온다.

cntCol2 = WorkSheets(1).Cells(2, Columns.Count).End(xlToRight).Column




'MySheet라는 시트에 셀 2,1(즉, B1)에 값을 입력할 수 있다. 시트 비활성화 상태에서도 가능

Worksheets("MySheet").Cells(2, 1).Value = "VBA Programming"


' 선택된 주소의 인접된 주소값 (기본값 예:$A$1:$B$10), 만약 $를 생략하고 싶을경우

' Selection.Address(0,0)을 입력하면 된다.

Range("A1").CurrentRegion.Select

Selection.Address


' 선택된 범위의 내용지우기

Selection.ClearContents


' 해당 셀에 .Value 값 입력하기

With Range("A1,A3,A5,A7,A9,B2,B4,B6,B8,B10")

    .Select

    .Value = "엑셀 VBA"

End With


로그인 후 댓글쓰기가 가능합니다.

?

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소