J
jfcby
Hello,
How can the following macro be modified to skip blank cells:
Sub NumberCellsValue()
Dim LastRow As Long
With ActiveSheet
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Font.Bold = False
Selection.ColumnWidth = 5
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
.Range("a1").Value = 1
With .Range("a2:a" & LastRow)
.FormulaR1C1 = "=IF(RC[1]=R[-1]C[1],R[-1]C+1,1)"
.Value = .Value
End With
.Range("a:a").NumberFormat = "000"
End With
Range("A1:A3").ClearContents
Range("A1").Select
End Sub
Thank you for your help,
jfcby
How can the following macro be modified to skip blank cells:
Sub NumberCellsValue()
Dim LastRow As Long
With ActiveSheet
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Font.Bold = False
Selection.ColumnWidth = 5
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
.Range("a1").Value = 1
With .Range("a2:a" & LastRow)
.FormulaR1C1 = "=IF(RC[1]=R[-1]C[1],R[-1]C+1,1)"
.Value = .Value
End With
.Range("a:a").NumberFormat = "000"
End With
Range("A1:A3").ClearContents
Range("A1").Select
End Sub
Thank you for your help,
jfcby