A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Great! Scenario 2 is completed. I may want to clear some question in the code before marking the thread as answered.
While processing column W in wsSource. Code introduces line breaks. But in the categories I use Wrap? I feel there is no need to introduce line breaks only remove the leading part from Column W.
And I don't have numbers in my Category. For sample data set I made up 1 to 4.
Those Categories have strings names. Like below.
RUOHS-0008 = Caterogy_1
RUACH-0260 = Caterogy_2
Rpo_70_sub = Caterogy_3
Sub_Restricted-Declrable = Caterogy_4
I have to edit the code now. For the loop part For lngCatNo = 1 To 4
Did not think you would use those numbers to loop lngCatNo = 1 To 4
Not sure if this effects the rest of the code.
Instead of changing the whole code can I assign those strings to the 1 to 4
Caterogy_1 = RUOHS-0008
Caterogy_2 = RUACH-0260
Caterogy_3 = Rpo_70_sub
Caterogy_4 = Sub_Restricted-Declrable
Not sure if that helps. Will I be able to filter with RUOHS-0008 from wsSource if I assign Caterogy_1 = RUOHS-0008
I tried
Dim Category_1 As Variant
Dim Category_2 As Variant
Dim Category_3 As Variant
Dim Category_4 As Variant
Category_1 = "RUOHS - 0008"
Category_2 = "RUACH - 0260"
Category_3 = "Rpo_70_sub"
Category_4 = "Sub_Restricted-Declrable"
and changed the wsSource as well
It did not work.
Could you suggest a better way to loop them.
Need to edit the below code.
strCatCol = "Category_" & lngCatNo 'Creates string to match column header (eg "Category_1" with underscore)
' strCatHeader = Replace(strCatCol, "_", " ") 'The Report header templace has a space in lieu of an underscore
lngLastUsedRow = LastRow(wbOut.Worksheets("Categories").Cells)
If lngLastUsedRow > 1 Then 'If Row 1 then no existing Category existing (First Category)
lngLastUsedRow = lngLastUsedRow + 2 'Move 2 rows down from last used row (one row gap)
End If
Set rngCatTemplate = FindCatHeader(wbThis.Worksheets("Categories").Cells, strCatHeader) 'Finds the individual template header
Set rngCatTemplate = rngCatTemplate.CurrentRegion 'Increase the range to include the entire current region
rngCatTemplate.Copy Destination:=wbOut.Worksheets("Categories").Cells(lngLastUsedRow, "A")