프로젝트를 하다보면 EXCEL VBA를 이용하여 대량의 데이터를 가공해야할 경우가 많은데 자주 까먹고 그래서 여기에 필요한 부분이 있으면 그때 그때 기록해서 활용해야겠당.
혹시 필요한 부분이 있다면 유용하게 쓰시길 바랍니다.
○ 지정된 Column의 Cell에 데이터가 있을경우 지정된 위치로 이동
Dim i Dim str
For i = 1 To 400 Step 1 str = Cells(i, 1).Text
If (Len(str) > 0) Then Cells(i, 5).Value = str Cells(i, 1).Clear End If Next i |
○ MS-WORD의 지정된 셀의 이름 지정과 셀의 넓이 조절
On Error GoTo ErrorHandler Selection.Tables(1).Cell(1, 4).Range.Text = "1차점검" Selection.Tables(1).Cell(1, 5).Range.Text = "2차점검" For i = 1 To 30 Step 1 Selection.Tables(1).Cell(i, 1).Width = CentimetersToPoints(0.8) Selection.Tables(1).Cell(i, 2).Width = CentimetersToPoints(1.2) Selection.Tables(1).Cell(i, 3).Width = CentimetersToPoints(5.8) Selection.Tables(1).Cell(i, 4).Width = CentimetersToPoints(1.04) Selection.Tables(1).Cell(i, 5).Width = CentimetersToPoints(1.04) Selection.Tables(1).Cell(i, 6).Width = CentimetersToPoints(5.49) Next i Selection.Tables(1).Cell(2, 5).Select
ErrorHandler: Resume Next |