Insert text above copy and pasted ranges from advanced filter

Livin404

Active Member
Joined
Jan 7, 2019
Messages
352
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings, I have a macro below which works properly by using advanced filter and pastes the range on to a second worksheet of the same workbook. This process runs about six times and works properly in all instances. What I'm looking for is a macro that will insert text above each result. It will be a description and instructions of each result. I suspect to make it work this will have to be done with a merged cell using text wrap. I only need to have those inserted rows with text to be merged with text wrap. The Columns will run from A to I. Thank you,

VBA Code:
Sub CatI_Filter()
Dim rgData As Range, rgCriteria As Range, rgOutput As Range
Dim sh As Worksheet
Dim LstRw As Long
Set rgData = ThisWorkbook.Worksheets("Database").Range("A8").CurrentRegion
Set rgCriteria = ThisWorkbook.Worksheets("Database").Range("A1").CurrentRegion
Set rgOutput = ThisWorkbook.Worksheets("Deficiencies").Range("A1")
Set sh = Sheets("Deficiencies")
With sh
LstRw = .Cells(.Rows.Count, "A").End(xlUp).Row + 2
Set rgOutput = .Range("A" & LstRw)
rgData.AdvancedFilter xlFilterCopy, rgCriteria, rgOutput
End With
End Sub
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Watch MrExcel Video

Forum statistics

Threads
1,118,525
Messages
5,572,641
Members
412,478
Latest member
MakeItWorkVBA
Top