+ Reply to Thread
Results 1 to 25 of 25

Find cells with today's date and copy asscoiated range

Hybrid View

  1. #1
    Registered User
    Join Date
    10-25-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    65

    Find cells with today's date and copy asscoiated range

    Hello,

    I have a spreadsheet where various dates are in column T.

    I require a vba code or macro that will do the following:

    Select all the rows in the range ("T:BP") where the date in T is today's date. Then copy the selection

    This must be simple but for some reason i am just not getting it!

    Would appreciate any help

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Find cells with today's date and copy asscoiated range

    Maybe:

    Sub paulary30()
    
    Dim lr As Long
    Dim rcell As Range
    
    lr = Cells(Rows.Count, 20).End(xlUp).Row
    
    For Each rcell In Range("T2:T" & lr)
    
        If rcell = Date Then
        
            Range(rcell, rcell.Offset(, 48)).Copy Sheets("Sheet2").Range("T" & Rows.Count).End(3)(2)
            
        End If
        
    Next rcell
    
    End Sub
    Untested, try on a copy first.

  3. #3
    Registered User
    Join Date
    10-25-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    65

    Re: Find cells with today's date and copy asscoiated range

    Quote Originally Posted by JOHN H. DAVIS View Post
    Maybe:

    Sub paulary30()
    
    Dim lr As Long
    Dim rcell As Range
    
    lr = Cells(Rows.Count, 20).End(xlUp).Row
    
    For Each rcell In Range("T2:T" & lr)
    
        If rcell = Date Then
        
            Range(rcell, rcell.Offset(, 48)).Copy Sheets("Sheet2").Range("T" & Rows.Count).End(3)(2)
            
        End If
        
    Next rcell
    
    End Sub
    Untested, try on a copy first.
    Hi,

    Thanks for your response

    I tried the code with my sheet but nothing is copying

    What does the 20 refer to in
    lr = Cells(Rows.Count, 20).End(xlUp).Row

  4. #4
    Registered User
    Join Date
    10-25-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    65

    Re: Find cells with today's date and copy asscoiated range

    When I get home, I will upload an example as i cannot do it from work

    Thanks

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Find cells with today's date and copy asscoiated range

    I just tested it and it worked on the sample I created. I used Sheet 2 for a destination sheet since you didn't mention a destination in your thread. Is there data filled in in Column T from the top row to the last row? It can be amended to another row if needed.

  6. #6
    Registered User
    Join Date
    10-25-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    65

    Re: Find cells with today's date and copy asscoiated range

    Hi,

    Column T has dates in it. I want to select all the cells in T which have today's date in them and all the cells along those rows up to column BP

    I don't need a paste function as I already have a paste macro which does some specific things.

    Much appreciated

  7. #7
    Registered User
    Join Date
    10-25-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    65

    Re: Find cells with today's date and copy asscoiated range

    I think I need something which does something like

    Look down column T
    Find all the cells with today's date
    select those cells and all the cells to the right of them up to column BP
    Copy all the selected cells

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Find cells with today's date and copy asscoiated range

    The 20 refers to the Column Number (T). I didn't test it can you provide a sample?

  9. #9
    Registered User
    Join Date
    10-25-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    65

    Re: Find cells with today's date and copy asscoiated range

    When I get home, I will upload an example as i cannot do it from work

    Thanks

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Find cells with today's date and copy asscoiated range

    Manos77,

    Are you asking a question or posting a solution? If its the former,

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

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