기분 열에 해당하는 문자가 있으면 그 문자로 나눠주는 프로그램이다.
예를들어서
I행에 |문자를 찾아서 밑으로 나눠주고 싶을때
이 매크로를 실행하면 아래처럼 변한다.
단지 계속 실행해야 하고, 마지막에 에러가 나긴 하지만..
그럭저럭 쓸만한거 같다.
Sub 매크로1()
'
' 매크로1 매크로
'
'
Dim i As Integer
Dim nFindPos As Integer
Dim nLen As Integer
Dim nFor As Integer
Dim strSourceLabel As String
Dim strFindLabel As String
Dim strNextLabel As String
strFindLabel = "|"
'I 열 중에서 strFindLabel 값을 찾음.
Range("I:I").Find(What:=strFindLabel, After:=ActiveCell, LookAt:= _
xlPart).Activate
nFor = Len(ActiveCell) - Len(Application.Substitute(ActiveCell, strFindLabel, ""))
strNextLabel = ActiveCell
If nFor > 0 Then
For i = 1 To nFor Step 1
'마지막 위치 기억
nLen = Len(strNextLabel)
'strFindLabel 의 위치를 찾음.
nFindPos = InStr(strNextLabel, strFindLabel)
'찾기 전의 값을 가져와서
strSourceLabel = Left(strNextLabel, nFindPos - 1)
' 현재 위치에 저장
ActiveCell = strSourceLabel
' 찾은 값 다음 값을 다시 기준으로 삼음.
strNextLabel = Mid(strNextLabel, nFindPos + 1, nLen)
'한줄을 삽입하고
Cells(ActiveCell.Row + 1, ActiveCell.Column).Select
Selection.EntireRow.Insert
'찾은 값을 다음 행에 저장
Cells(ActiveCell.Row, ActiveCell.Column) = strNextLabel
Next i
End If
End Sub
'page 1 .컴퓨터 > 문서작성' 카테고리의 다른 글
[EXCEL] 매그로 편집 안될 때 (0) | 2013.04.26 |
---|---|
[Excel] 문장 끝에 특정 문자 지우기 (0) | 2013.03.29 |
엑셀 VLOOKUP 왼쪽 값 찾기 (0) | 2013.03.26 |
엑셀 단축키 행선택, 열선택, 전체 선택, 자동 채우기 (2) | 2013.03.26 |
엑셀 Reversed Find (0) | 2013.03.26 |