Sub 행값매기기()
Dim r As Range
Dim rng As Range
Dim rowsCnt As Long
Dim k As Variant
Set r = Range(Cells(2, "ag"), Cells(Rows.Count, "AG").End(3))
rowsCnt = Cells(Rows.Count, 33).End(3).Row
Set rng = Range(Cells(2, "ah"), Cells(rowsCnt, "ah"))
Range(Cells(2, "ah"), Cells(Rows.Count, "ah")).ClearContents
Cells(2, "ah").Select
Application.ScreenUpdating = False
For Each k In rng
If Cells(ActiveCell.Row, ActiveCell.Column - 1).Value <> "" Then
Cells(ActiveCell.Row, "AH").Formula = "=ROW()-1"
Cells(ActiveCell.Row + 1, ActiveCell.Column).Select
End If
Next k
Application.ScreenUpdating = True
End Sub
버전업========== ========== ========== ========== ==========
Sub 행값매기기()
Dim rng As Range
Dim rowsCnt As Integer
rowsCnt = Cells(Rows.Count, "ag").End(3).Row
Set rng = Range(Cells(2, "ah"), Cells(rowsCnt, "ah"))
Range(Cells(2, "ah"), Cells(Rows.Count, "ah")).ClearContents
rng.Formula = "=ROW()-1"
rng.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Cells(2, "ah").Select
End Sub
'컴퓨터 > 엑셀' 카테고리의 다른 글
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 |
다중조건 텍스트 가져오기-배열식이용 (0) | 2018.02.07 |