copy data for meeting condition in multiple times

cds

Board Regular
Joined
Mar 25, 2012
Messages
82
I have following data wherein I want copy data between all "sr" and "extra" to separate sheet . I have following vba which copies data from first meeting of find conditions ie., row after sr and one row before extra, which is perfect. But same worksheet I have more data which succeed with "sr" and proceeds with extra which I am not not able to copy. again, I want add column in the data sheet and for first meeting sr & extra combination I want add "1" in new column and 2 for next and so on Thereafter I want to transpose them as shown in output . I have attached sample data and output image Kindly help me out .
VBA Code:
Sub loop_through_all_worksheetsnnN12()
Sheets("Sheet1").Select
Dim ws As Worksheet
Dim starting_ws As Worksheet
Dim wsResults As Worksheet
Set starting_ws = ActiveSheet 'remember which worksheet is active in the beginning
Application.ScreenUpdating = False
  For Each ws In ActiveWorkbook.Worksheets
        If ws.Name <> "matches"
                ws.Activate
   With ws
    
           With Range("d" & Columns("c").Find(What:="SRg", LookAt:=xlPart, MatchCase:=False).Row + 1 & _
              ":d" & Columns("c").Find(What:="Extra", LookAt:=xlPart, MatchCase:=False).Row - 1)
      
                   Sheets("Scoresheet").Activate
                   Set wsResults = ActiveSheet

                 .Offset(0).Resize(.Rows.Count).EntireRow.Copy Destination:=wsResults.Range("a" & Rows.Count).End(xlUp).Offset(1, 0)

             End With
End With
    End If

  Next
  Application.ScreenUpdating = True
End Sub
mydata.PNG
 
Last edited by a moderator:

Forum statistics

Threads
1,082,360
Messages
5,364,935
Members
400,815
Latest member
Joaquin Phoenix

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top