PDA

View Full Version : Solved: Add an Auto increment number in blank cell in column A



parscon
04-08-2013, 05:26 AM
I have a list in column A that there is a bank row between rows. Now I need add Auto increment number on blank rows and start from 4 till to up.

That mean:

A1: Blank
A2: DATA
A3: DATA
A4: Blank
A5: DATA
A6: DATA
A7: DATA
A8: Blank

After run VBA code will be:

A1: 4
A2: DATA
A3: DATA
A4: 5
A5: DATA
A6: DATA
A7: DATA
A8: 6

Also I added a Sample file enclosed this post.

Thank you very much

GarysStudent
04-08-2013, 06:12 AM
Perhaps something like:

Sub dural()
Dim N As Long: N = 4
Dim LastRow As Long, L As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For L = 1 To LastRow
If Cells(L, 1).Value = "" Then
Cells(L, 1).Value = N
N = N + 1
End If
Next L
End Sub

parscon
04-08-2013, 06:18 AM
Thank you very much just another thing cloud you please help me the number will be in column B .

Thank you again .

GarysStudent
04-08-2013, 06:26 AM
Here it is:

Sub dural()
Dim N As Long: N = 4
Dim LastRow As Long, L As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For L = 1 To LastRow
If Cells(L, 1).Value = "" Then
Cells(L, 1).Offset(0, 1).Value = N
N = N + 1
End If
Next L
End Sub

parscon
04-08-2013, 06:33 AM
Thank you very much , it is completed .