Trying to write a code to insert a blank row above a cell value

Solved/Closed
Kwanni Posts 2 Registration date Monday 24 June 2013 Status Member Last seen 26 June 2013 - 24 Jun 2013 à 13:06
Ambucias Posts 47312 Registration date Monday 1 February 2010 Status Moderator Last seen 28 March 2026 - 26 Jun 2013 à 16:54
I am trying to write a code that will auto insert a blank row above a certain cell value ie:

existing:

Column G

5
10
20
22
999
2
22
55
999
22
32

Need it to look like this:

Column G

5
10
20
22

999
2
22
55

999
22
32

Everytime the value in a cell in column G is 999, a blank row is inserted above it.
Thank you
Related:

3 responses

venkat1926 Posts 1863 Registration date Sunday 14 June 2009 Status Contributor Last seen 7 August 2021 811
26 Jun 2013 à 02:28
when you entere numbers without unnecessary space before or after the number

then run this macro

Sub test()
Dim r As Range, cfind As Range, add As String
Worksheets("sheet1").Cells.Clear
Worksheets("sheet2").Cells.Copy Worksheets("sheet1").Range("A1")
Worksheets("sheet1").Activate
Dim j As Integer, k As Integer
j = Range("A1").End(xlDown).Row
For k = j To 1 Step -1
If Cells(k, 1) = 999 Then Cells(k, 1).EntireRow.Insert
Next k
End Sub
Ambucias Posts 47312 Registration date Monday 1 February 2010 Status Moderator Last seen 28 March 2026 11,166
26 Jun 2013 à 16:54
Venkat is our home genius!
Kwanni Posts 2 Registration date Monday 24 June 2013 Status Member Last seen 26 June 2013
26 Jun 2013 à 12:57
Thank you so much for taking the time to help me.
Saved me hours of work.