How can I fInd cells in a column that do not have the correct sequence of data in.

Davebro

Board Regular
Joined
Feb 22, 2018
Messages
135
Office Version
  1. 365
  2. 2021
  3. 2016
Platform
  1. Windows
I have a column which consits of 6 cells of data and then a two space but some rows only have 5 cells of data, how can I identify the ones with 5 and add a row to make it 6 (8 in all).
Races_2023_22_04_06_58.csv
A
932
1039
1138
1236
1340
1439
15
16
1734
1824
1924
2034
2138
22
23
2427
2540
2642
2735
2838
2939
30
31
328
3320
3431
3527
3627
37
38
3913
4033
4138
4237
4327
4427
45
46
4735
4830
4925
5015
5141
5223
53
54
5537
5635
5730
5810
5922
6030
Sheet1
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Does this do what you want? I have assumed that the values shown are not the result of formulas.
Test with a copy of your data.

VBA Code:
Sub CheckRowNumbers()
  Dim rA As Range
  
  Const RowsRequired As Long = 6
  
  Application.ScreenUpdating = False
  For Each rA In Range("A9", Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlConstants).Areas
    If rA.Count < RowsRequired Then rA.Offset(rA.Count).Resize(RowsRequired - rA.Count).EntireRow.Insert
  Next rA
  Application.ScreenUpdating = True
End Sub
 
Upvote 1
Solution
Hi, many thanks for this, yes it works fine, still getting to grips with VBA but this explains a bit more to me.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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