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:
1) Read Date input (End of the week date) by User in B4 on the Master Monthly-Weekly Totals sheetPublic 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
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.
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]
Sorry about that, here you go and thanks in advance:
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.Set rng = .Range("A1:A53").Find(What:=WEDate, LookIn:=xlValues)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks