컴퓨터/엑셀

공부할것

풍경소리^^ 2018. 6. 3. 15:52

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

'컴퓨터 > 엑셀' 카테고리의 다른 글

vba countifs 함수 "문자"  (0) 2018.06.06
vba countifs  (0) 2018.06.04
행번호매기기  (0) 2018.06.03
ActiveCell.Offset(1, 2).Range("A1").Select  (0) 2018.05.15
시트이동,행렬바꾸기  (0) 2018.04.19