ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding new rows (https://www.excelbanter.com/excel-programming/300789-adding-new-rows.html)

sk8rider

Adding new rows
 
Hello,

Any help with this solution would be greatly appreciated.

I have two sheets (sheet1 and sheet2). In sheet1 one I do som
filtering. Sheet2 looks like this:

Priority1


Priority2
Priority3



Priority4

I would like to move the results(rows) from the filtered sheet1 an
insert between Priority2 and Priority3, and push down the labe
Priority3.

Thanks in advace

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Adding new rows
 
Sub Tester1()
Dim rng As Range, rng1 As Range
Dim rng2 As Range
With Worksheets("Sheet1")
Set rng = .AutoFilter.Range
End With
Set rng = rng.Offset(1, 0).Resize(rng.Rows.Count - 1)
numRow = rng.Columns(1).SpecialCells(xlVisible).Count
rng.Copy
With Worksheets("Sheet2")
Set rng1 = .Columns(1).Find("Priority3")
End With
If Not rng1 Is Nothing Then
Set rng2 = rng1.Offset(-1, 0)
rng1.EntireRow.Resize(numRow).Insert
rng.Copy
Worksheets("Sheet2").Paste rng2.Offset(1, 0)
End If

End Sub

--
Regards,
Tom Ogilvy



"sk8rider " wrote in message
...
Hello,

Any help with this solution would be greatly appreciated.

I have two sheets (sheet1 and sheet2). In sheet1 one I do some
filtering. Sheet2 looks like this:

Priority1


Priority2
Priority3



Priority4

I would like to move the results(rows) from the filtered sheet1 and
insert between Priority2 and Priority3, and push down the label
Priority3.

Thanks in advace.


---
Message posted from http://www.ExcelForum.com/




sk8rider[_2_]

Adding new rows
 
Thanks a lot Tom your post helped me resolved my issue.

Take care

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 12:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com