Results 1 to 2 of 2

Find and copy row containing today's date

Threaded View

  1. #1
    Registered User
    Join Date
    06-21-2011
    Location
    Great Lakes, IL
    MS-Off Ver
    Excel 2007
    Posts
    1

    Find and copy row containing today's date

    Hi, I found this macro on a post and modified it to my needs. It works on one worksheet but not another. The verbage is the same except the names of the worksheets and destination worksheets. It appears that for some reason the "find" function just isn't working on this one but it DOES work on another worksheet in the same workbook. Any ideas? Thanks for any help!
    Sub INCIDENTS_CopySignificant()
      'Copy cells of cols A,C from rows containing TODAY() in
      'col B of the active worksheet (source sheet) to cols
      'A,B,C of INCIDENTS_LEAVE_SNAPSHOT (destination sheet)
      Sheets("INCIDENTS_LEAVE").Select
      Range("A1").Select
      Dim DestSheet        As Worksheet
      Set DestSheet = Worksheets("INCIDENTS_LEAVE_SNAPSHOT")
      
      Dim sRow       As Long     'row index on source worksheet
      Dim dRow       As Long     'row index on destination worksheet
      Dim sCount     As Long
      sCount = 0
      dRow = 1
    
      For sRow = 1 To Range("D655").End(xlUp).Row
         'use pattern matching to find TODAY'S DATE anywhere in cell
         If Cells(sRow, "B") = Date Then
            sCount = sCount + 1
            dRow = dRow + 1
            'copy cols A,C
            Cells(sRow - 1, "A").Copy Destination:=DestSheet.Cells(dRow, "A")
            Cells(sRow, "A").Copy Destination:=DestSheet.Cells(dRow, "b")
            Cells(sRow, "C").Copy Destination:=DestSheet.Cells(dRow, "c")
         End If
      Next sRow
      
      MsgBox sCount & " Significant rows copied", vbInformation, "Transfer Done"
    
        End Sub
    Last edited by Paul; 06-21-2011 at 03:54 PM. Reason: Added code tags for new user. Please read the forum rules before posting again, thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1