2018년 11월 7일 수요일

Excel VBA 특정 컬럼 명(1열) 만 남기고 삭제하기.

대량 작업시 유용...

Sub Delete_Cols_WithOut()

    Dim co As Long, I As Long
    Dim join As String

    co = ActiveSheet.Range("A1").CurrentRegion.Columns.Count '추가할 시트에 Cols count 를 알아옵니다
    
    Debug.Print ("#시트이름 : " + ActiveSheet.NAME)
    Debug.Print ("--컬럼 목록 시작")
    For I = 0 To co
        Cells(1, I + 1).Select
        join = Selection.Offset(0, 0) ' 비교할셀값 좌표
        Debug.Print (join)
    Next
    Debug.Print ("--컬럼 목록 끝")
    Debug.Print ("--------------------------------")

    Cells(1, 1).Select

    For I = 0 To co
        join = Selection.Offset(0, 0) ' 비교할셀값 좌표
        'Debug.Print (join)
    
            If join = "Key" Or join = "삭제할 시트명" Then
                Debug.Print ("찾음 : +" + join)
                Selection.Offset(0, 1).Select    
            Else
                Debug.Print ("삭제함 : -" + join)
                Selection.EntireColumn.Delete
    
            End If

    Next

End Sub

댓글 1개:

  1. Whether you're be} enjoying in} roulette or blackjack, or another sport for that matter, it is all the time 먹튀검증사이트 necessary to know the sport thoroughly. Make it your small business to be told about the house edge, which is the percentages of the on line casino successful over the participant, and the payout percentage. This will at least of|no much less than} provide you with an affordable likelihood of successful some cash earlier than your price range is completely depleted. Throughout this article, we’ll present you how the Big Spin Casino bonus code works, the place to enter it and the way to|tips on how to} go about getting the most from the bonus.

    답글삭제