|
* 답변하시는 분들께 도움이 되도록 자신의 환경을 아래 항목 옆에 기재해 주세요.
- 엑셀 버전(95,97,2000,xp,2003,2007): EXCEL OFFIC 2013, WINDOWS 7 PROPESIONAL 64 BIT
* 아래줄에 질문을 작성하세요 >>
정보가 있는 시트에서 해당월에 금액이 있는 경우만 데이터를 가져와 재배치 하는 매크로 인데
반복문에서 2 TO 10으로 하면 1회는 정상적으로 작동 되는데
2회 또는 처음부터 반복문 구간을 20이상 주게 되면
VBA 80010108 런타임 오류를 뱉어냅니다. 디버그 창으로 가게 되면
Selection.Insert Shift:=xlDown 부분으로 이동
무시하고 다시 한번 더 실행하니
1004 런타임 오류가 발생했습니다. 라고 뜨고
디버그창이 Selection.Copy 쪽으로 이동합니다.
어느 구문이 잘못돼서 이 에러가 발생하는지 검색해도 다른얘기 같고,
검색하다보니 ACTIVE 셀 어쩌고 써있어서
ACTIVECELL 부분을 주석처리 하니 반복문은 수행이 됩니다.
하다보니 1004 런타임 오류는 빈번하게 발생하는 것 같은데
어느 부분이 잘못됐는지 답변 주시면 감사하겠습니다.
아래는 VBA 매크로 내용 입니다.
Sub 매크로1()
'
' 매크로1 매크로
'
' 바로 가기 키: Ctrl+Shift+Q
'
Dim STRNum As Integer
Dim ENDNum As Integer
STRNum = InputBox("시작값")
ENDNum = InputBox("종료값")
For i = STRNum To ENDNum
금액 = Range("거래처목록!K" & i).Value
상호 = Range("거래처목록!B" & i).Value
주소 = Range("거래처목록!A" & i).Value
번호 = Range("거래처목록!D" & i).Value
If 금액 > 0 Then
Range("A1:D8").Select
Selection.Copy
Selection.Insert Shift:=xlDown
Range("A13:A15").Select
Application.CutCopyMode = False
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("D10:D15").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("A9").Select
ActiveCell.FormulaR1C1 = 상호
Range("B9").Select
ActiveCell.FormulaR1C1 = 주소
Range("C9").Select
ActiveCell.FormulaR1C1 = 번호
Range("B11").Select
AtiveCell.FormulaR1C1 = 금액
Range("B12").Select
Else
End If
Next i
End Sub
|
|