컴퓨터/엑셀

vba 행번호매기기

풍경소리^^ 2018. 6. 6. 10:32

Sub 행값매기기()
Dim rng As Range
Dim rowsCnt As Integer
    rowsCnt = Cells(Rows.Count, "d").End(3).Row
    Set rng = Range(Cells(2, "AC"), Cells(rowsCnt, "AC"))
    Range(Cells(2, "AC"), Cells(Rows.Count, "AC")).ClearContents
   
    rng.Formula = "=ROW()-1"
    rng.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Cells(2, "AC").Select
   
End Sub