0

I have tried so many ways to make this work and its just not! j is the # of tabs its searching through (TailValue is an arraylist.Tested & works). k is the # of rows its supposed to be searching (Starting on Row 2 ending on Row 12). WantedDate is a text box for the date to search.

What I need it to do: Go through each tab. Find any date that matches the WantedDate (Only search Rows A2:A12). Copy the entire row and either paste it or insert it on the 2nd Row of the Mx EOD Tab

Every time I get it to atleast kind of function it pulls a random rows on each tab and/or it pulls the wrong date and inserts it on the MX EOD Tab twice.

If the "If Statement" needs an "Else" (If the date does not match the wanted date) I need it to move to the next row in the range and compare. There can be multiple rows with this date. Thank you for any and all help!!

For j = 0 To 20 'Or to LastRow (Cant figure out how to get the last row with text)

    For k = 2 To 15 'Or to LastRow ("")
    
           If Worksheets(TailValue(j)).Cells(k, 1).Value = WantedDate Then
               Worksheets(TailValue(j)).Rows(ActiveCell).EntireRow.Copy
               Worksheets("Mx EOD").Activate
               Rows(2).Insert
           End If
    Next k
Next j
Beau
  • 11
  • 4
  • [finding the last row in a column](https://stackoverflow.com/questions/71180/how-can-i-find-last-row-that-contains-data-in-a-specific-column?r=SearchResults&s=2|88.4206) – cybernetic.nomad May 12 '22 at 17:15
  • Don't use `Rows(ActiveCell)` use `Rows(j)` instead. The activecell is not always the one you think it is (you didn't activate any cells so it,s whatever was last selected on any given sheet) – cybernetic.nomad May 12 '22 at 17:17
  • Change the last two lines in the loop to: `Worksheets("Mx EOD").Rows(2).Insert` – cybernetic.nomad May 12 '22 at 17:18

0 Answers0