• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to Insert Row above QTY

Slohman


Try the following:

[pre]
Code:
Sub Insert_Row_on_Qty()

Dim c As Long
For c = Range("F1").End(xlDown).Row To 1 Step -1
If UCase(Cells(c, 6)) = "QTY" Then Cells(c, 6).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Next

End Sub
[/pre]

Please also use lower case when posting
 
Whoops, here 'tis

[pre]
Code:
Sub Insert_Row_on_Qty()

Dim c As Long
For c = Range("F1").End(xlDown).Row To 1 Step -1
If UCase(Cells(c, 6)) = "QTY" Then Rows(c).Insert Shift:=xlDown
Next

End Sub
[/pre]
 
Sorry I think Im confusing you. I need it to keep the row that Qty is in and add blank row above as Qty is a heading
 
So you say - I need it to keep the row that Qty is in and add blank row above as Qty is a heading

But mean - I need it to keep the row that Qty is in and add blank row Below as Qty is a heading

[pre]
Code:
Sub Insert_Row_on_Qty()

Dim c As Long
For c = Range("F1").End(xlDown).Row To 1 Step -1
If UCase(Cells(c, 6)) = "QTY" Then Rows(c + 1).Insert Shift:=xlDown
Next

End Sub
[/pre]
 
Back
Top