Excel 매크로의 기본 논리 문

7715 단어 Excel

IF 문

Sub  ()
'    
    If Selection.Font.Underline = xlUnderlineStyleDoubleAccounting Then
        Selection.Font.Underline = xlUnderlineStyleNone
    Else
        Selection.Font.Underline = xlUnderlineStyleDoubleAccounting
    End If
End Sub

For 루프 및 매크로 상대 참조, 절대 참조

Sub  ()
'    
    Range("B1").Select
    
    ActiveCell.Range("A1:A6").Select
    
    For counter = 1 To 65
    
        Selection.Font.Bold = True
        ActiveCell.Offset(6, 0).Range("A1:A6").Select
        Selection.Font.Italic = True
        ActiveCell.Offset(6, 0).Range("A1:A6").Select
    
    Next counter
End Sub

Do While 순환

Sub  ()
'
'  11  
'
    Range("B1").Select
    
    ActiveCell.Range("A1:A6").Select
    
    Do While ActiveCell <> ""
    
        Selection.Font.Bold = True
        ActiveCell.Offset(6, 0).Range("A1:A6").Select
        Selection.Font.Italic = True
        ActiveCell.Offset(6, 0).Range("A1:A6").Select
        
    Loop
End Sub

Do Until 순환

Sub  ()
'
'  11  
'
    Range("B1").Select
    
    ActiveCell.Range("A1:A6").Select
' Do Until IsEmpty(ActiveCell)
    Do Until ActiveCell = ""
    
        Selection.Font.Bold = True
        ActiveCell.Offset(6, 0).Range("A1:A6").Select
        Selection.Font.Italic = True
        ActiveCell.Offset(6, 0).Range("A1:A6").Select
        
    Loop
End Sub

좋은 웹페이지 즐겨찾기