+ Reply to Thread
Results 1 to 4 of 4

Thread: Copy column data on one sheet to row or column date on another sheet based on user in

  1. #1
    Registered User
    Join Date
    01-11-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Copy column data on one sheet to row or column date on another sheet based on user in

    I would like to copy data on a Master sheet to a Weekly sheet to retain the values for each week.
    I have this code, but it doesn't find the date for some reason:

    Public Sub copycolumns()
    
      Dim rng As Range
      Dim WEDate As String
      Dim Monthws As String
      Dim Weekws As String
      
      Monthws = "Master Monthly-Weekly Totals"
      Weekws = "Weekly"
      WEDate = Worksheets(Monthws).Range("B4").Value 'Get Week ending Date
      
      If WEDate = "1/8/2012" Then
        MsgBox "The Dates Match"
      Else
        MsgBox "The Dates Don't Match"
      End If
      
      With Worksheets(Monthws)
        'WEDate = Worksheets(Monthws).Range("B4").Value 'Get Week ending Date
        Set rng = Worksheets(Monthws).Range("D1:D128").Find("Weekly Running Total", LookIn:=xlValues)
        rng.Offset(2, 0).Resize(rng.End(xlDown).Rows + 3).Copy
        Application.CutCopyMode = False
     
      With Worksheets(Weekws)
        Set rng = .Range("A1:A53").Find(What:=WEDate, LookIn:=xlValues)
        
        If Not rng Is Nothing Then
           ActiveSheet.Cells(1, 0).PasteSpecial Paste:=xlPasteValues
           rng.Offset(1, 0).Resize(rng.End(xlDown).Row - 1).PasteSpecial (xlPasteAll)
        End If
     End With
    End With
    1) Read Date input (End of the week date) by User in B4 on the Master Monthly-Weekly Totals sheet
    2) Copy Data in Column D
    3) Go to Worksheet "Weekly" and find the same date input by the user, and paste the data to that column

    I think the problem here is the Find(What:=WEDate), I've tried Find(WEDate), even tried Find(CDate(WEDate)), Excel always finds Nothing, so my paste code never executes.
    Attached Files Attached Files

  2. #2
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,383

    Re: Copy column data on one sheet to row or column date on another sheet based on use

    Where is the "Weekly" worksheet? Its not visible in the workbook.
    Cheers,
    Arlette

    If I 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]

  3. #3
    Registered User
    Join Date
    01-11-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Copy column data on one sheet to row or column date on another sheet based on use

    Sorry about that, here you go and thanks in advance:
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-11-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Copy column data on one sheet to row or column date on another sheet based on use

    Set rng = .Range("A1:A53").Find(What:=WEDate, LookIn:=xlValues)
    This line always returns Nothing, any idea why. I can get everything to work except code to find the matching date (Column Headers on Weekly Sheet) and paste the data to that column. I can hit enter in a cell and it pastes exactly what I want. But I don't want to have to do that. I want the code to copy from master sheet based on the date input by a user in cell B4; copy cells D7:D128; go to weekly sheet, find the matching date and paste to that column when the date is found.

+ 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.2.0