본문 바로가기

공부/VBA

VBA - Early Binding vs. Late Binding Early Binding (초기 바인딩) 도구->참조 대화상자에서 사용하려는 개체 라이브러리(Object Library)를 참조에 포함시킨다. 아래 코드와 같이 개체를 생성 Dim WordApp As New Word.Application Late Binding (지연 바인딩) Dim WordApp As Object Set WordApp = CreateObject("Word.Application") Early, Late Binding 둘다 "Word.Application"이라는 이름을 사용하지만 서로 참조하는 것이 다름. Early Binding에서의 "Word.Application"은 개체 라이브러리를 참조. Late Binding에서의 CreateObject함수의 "Word.Application"은 윈.. 더보기
VBA - Application.OnTime Method 초단위 조작만 가능, 타이머 핸들러내에 타이머 재등록 함수를 호출하여 periodic timer를 구현 가능함. 단, 이 경우 등록된 타이머를 취소하는 방법에 유의. 기존에 등록된 타이머가 남아있으면 엑셀이 재 시작된다. 자세한 사용 예제 참조: http://www.cpearson.com/excel/OnTime.aspx Application.OnTime Method Schedules a procedure to be run at a specified time in the future (either at a specific time of day or after a specific amount of time has passed). Syntax expression.OnTime(EarliestTime, Proce.. 더보기
VBA - format 함수 사용법 Format("210.6", "#,##0.00") would return '210.60' Format("210.6", "Standard") would return '210.60' Format("0.981", "Percent") would return '98.10%' Format("1267.5", "Currency") would return '$1,267.50' Format("Sep 3, 2003", "Short Date") would return '9/3/2003' 더보기
VBA - Me keyword Private Sub OKButton_Click() 'Routines... Unload Me End Sub Me The Me keyword behaves like an implicitly declared variable. It is automatically available to every procedure in a class module. When a class can have more than one instance, Me provides a way to refer to the specific instance of the class where the code is executing. Using Me is particularly useful for passing information about the .. 더보기
VBA - Type Conversion Functions VBA에서 형변환 관련 함수 모음 Syntax CBool(expression) CByte(expression) CCur(expression) CDate(expression) CDbl(expression) CDec(expression) CInt(expression) CLng(expression) CLngLng(expression) (Valid on 64-bit platforms only.) CLngPtr(expression) CSng(expression) CStr(expression) CVar(expression) The required expression argument is any string expression or numeric expression. Return Types The function n.. 더보기
VBA - The On Error Statement On Error Goto 0 On Error Resume Next On Error Goto : 1. VBA의 디폴드 모드. 런타임 에러 발생시 에러 메시지를 보이고 사용자가 디버깅을 할 것인지, VBA 프로그램을 끝낼 것인지 선택할 수 있도록 한다. 2. 에러를 무시하는 모드. 에러로 인한 side effect가 있을 수 있으니 사용시 주의 필요. 3. 에러 발생시 특정 error handler로 점프. 상세설명, 출처: http://www.cpearson.com/excel/errorhandling.htm 더보기
엑셀 함수 - 지난 기간 구하기: NETWORKDAYS, TODAY 해당 날짜가 오늘자 기준으로 얼마나 지났는지 구하는 함수 사용법 =NETWORKDAYS(C11, TODAY()) 더보기
VBA on-line 도움말이 나오지 않을 경우 확인 사항 VBA 프로그래밍 시에 Excel 2010의 기본 도움말을 참조할 일이 많은데, 간혹 (알 수 없는 이유로) 아래와 같이 도움말의 온라인 접속이 되지 않을 때가 있다. 컴퓨터 내에 설치된 도움말에서만 찾아보도록 하면 온라인을 통해서 보는 내용보다는 제한적인 내용이지만 기본적인 사용이 가능하다. 아래와 같이 설정해 주면 된다. 온라인 접속 없이 기본적인 내용 확인이 가능하다. 더보기