엑셀VBA 유용한 명령어 모음
|
dim c as range
msgbox c.column '열번호
msgbox c.row '행번호
2. 엑셀 제목표시줄에 글자 표시
Application.Caption = ""
파일이름이 들어가는 제목표시줄 부분에 글자가 표시된다.
3. 특정시트로 이동
SHT = "시트이름"
Sheets(SHT).Select
4. 특정셀 선택
Range("A1").Select
5. 현재 활성화된 셀의 위치
현재셀
ActiveCell.Offset(0, 0)
현재 셀의 위 치에서 위로 6칸 까지의 범위
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(-6, 0))
현재 셀의 위 치에서 위로 6칸 까지의 범위 선택
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(-6, 0)).Select
6. 특정시트의 값 가져오기
Worksheets(SHT).Range("A1").Value
7. A열인지 아닌지 확인
If ActiveCell.Offset(0, 0).Column <> 1 Then
8. 현재 셀 기억
줄 기억 => a = ActiveCell.Offset(0, 0).Row
칸 기억 => a = ActiveCell.Offset(0, 0).Column
주소 기억 => b = ActiveCell.Offset(0, 0).Address
9. 셀 드래그
a = ActiveCell.Offset(?, ?).Address
b = ActiveCell.Offset(?, ?).Address
Range(a & ":" & b).Select
10. 글꼴 조정
Range("A1:D1").Select
Selection.Font.Bold = False
Selection.Font.Name = "돋움"
Selection.Font.Size = 11
11. 배경 없음
Range("A1:D1").Select
Selection.Interior.Pattern = xlNone
Selection.Interior.TintAndShade = 0
Selection.Interior.PatternTintAndShade = 0
12. 배경 노란색
Range("A1:D1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
13. 한 줄 아래로
ActiveCell.Offset(1, 0).Select
(한 줄 오른쪽은 0, 1)
14. 특정글자 변경(Replace)
b = Replace(a, "x", "*") 'x를 *로 바꿈
15. 검색
aaaa = "문자열"
On Error Resume Next '오류가 나도 다음으로
Cells.Find(What:=aaaa, After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext _
, MatchCase:=False, MatchByte:=False, SearchFormat:=False).Activate
If Err <> 0 Then 'MsgBox "검색된 셀이 없습니다", 64, "검색 실패"
Err.Clear
End If
On Error GoTo 0
16. 마지막행 찾기
LastRow = Columns(3).End(xlDown).Row 'c 열의 마지막 행을 찾음
17. 엑셀 색상 코드표
"Font.ColorIndex" 또는 "Interior.ColorIndex" 이런 식으로 사용되는
ColorIndex 라는 속성의 값을 표로 만든 것입니다.
ColorIndex 라는 속성은 0~56까지의 값을 지정할 수 있는데
각각의 숫자는 색을 의미합니다.
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | |
54 | |
55 | |
56 |
댓글