Add next sequence number in next blank row cell only..Excel VBA program

Akash030193

New Member
Joined
Apr 28, 2019
Messages
22
Hello! I need your help in below query.

I am looking for a VBA program that help me to add next sequence number in next blanks row cell only (one cell only). For example, 5th row is blank cell, i need to place next sequence number as "3". Similarly in the same column, refer row 9, i need to place next sequence number as "3"... similarly for all subsequent series..

1) Question
A
1Revision
20
31
42
5
60
71
82
9
100
111
122
13
140
151
162
17

<tbody>
</tbody>

After applying macro
A
1Revision
20
31
42
53
60
71
82
93
100
111
122
133
140
151
162
173

<tbody>
</tbody>


2) Second Example

Question

A
10
20
30
4
50
60
7

<tbody>
</tbody>


After applying macro

A
10
20
30
41
50
60
71

<tbody>
</tbody>


Code to be run if there is any next blank row in the column "A", and to be run for one next cell only.



https://1drv.ms/x/s!AgoBOBbQ2MyJgQcKF83--PVdg_3j



****** id="cke_pastebin" style="position: absolute; top: 0px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">A1Revision2031425
6071829
10011112213
14015116217
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi. Try:
Code:
Sub AddNextInBlanks()
 With Range("A2:A" & Cells(Rows.Count, 1).End(3).Row + 1)
  .SpecialCells(xlBlanks).FormulaR1C1 = "=R[-1]C+1"
  .Value = .Value
 End With
End Sub
 
Upvote 0
You can also do it directly without adding and then replacing formulas...
Code:
[table="width: 500"]
[tr]
	[td]Sub AddNextInBlanks()
 With Range("A2:A" & Cells(Rows.Count, 1).End(3).Row + 1)
  .Value = Evaluate("IF(" & .Address & "=""""," & .Offset(-1).Address & "+1," & .Address & ")")
 End With
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
Thanks Rick,

This program is also working well. Thank you once again for your support. I am grateful to you......
:):):)

Regards,
Akash Patel
 
Upvote 0
In continuation to thread message, can you please provide macro program as per below table?

I want to add next sequence number in below table with prefix "R". If my cell value is R1, then after in next first blank cell it needs to be R2...vice verse.....
Question
A
1R0
2R1
3
4R0
5R1
6
7R0
8
9R0
10R0
11

<tbody>
</tbody>
Answer
A
1R0
2R1
3R2
4R0
5R1
6R2
7R0
8R1
9R0
10R0
11R1

<tbody>
</tbody>
 
Upvote 0
In continuation to thread message, can you please provide macro program as per below table?

I want to add next sequence number in below table with prefix "R". If my cell value is R1, then after in next first blank cell it needs to be R2...vice verse.....
Give this macro a try...
Code:
Sub FillBlankWithOneMoreThanPreviousRnumber()
  Dim Ar As Range
  For Each Ar In Columns("A").SpecialCells(xlConstants).Areas
    Ar(Ar.Count).Offset(1).Value = "R" & Mid(Ar(Ar.Count), 2) + 1
  Next
End Sub
 
Upvote 0
Rick,

Can you share simple macro program in which I can fill blank cell with some text. For example,

Where there is blank cell in column A, I can fill blank cell with Text as per below tables.

A
1Apple
2Banana
3
4Grapes
5
6
7Carrot

<tbody>
</tbody>

A
1Apple
2Banana
3Not allocated
4Grapes
5Not allocated
6Not allocated
7Carrot

<tbody>
</tbody>
 
Upvote 0
Rick,

Can you share simple macro program in which I can fill blank cell with some text. For example,

Where there is blank cell in column A, I can fill blank cell with Text as per below tables.
Assuming the blanks are real blanks (not formulas displaying ""), give this macro a try...
Code:
Sub NotAllocated()
  Range("A1", Cells(Rows.Count, "A").End(xlUp)).SpecialCells(xlBlanks) = "Not allocated"
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,020
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top