VBA to Paste to destination according to date next to destination

Kankuroo

New Member
Joined
May 2, 2014
Messages
5
Hi Guys!

I have been looking around for some advice on how to do this, and it seams to be more complicated than I anticipated. So far I have only found a way to do the opposite of what I am after and cannot figure out how to reverse it.

My problem:
I have a range of values in cell D1:N1 in Sheet 2 and a plain date (03-Mar-2019) in cell C1, both in Sheet2.
In Sheet1 I have a list of dates in Column C.
What I need is to copy the content data from D1:N1 in Sheet2, and paste-values in Column D in Sheet 1, next to the date that match the date in C1 of Sheet2

Any pointers will be greatly appreciated.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
try this

Code:
Sub CopyValues()
    Application.ScreenUpdating = False
    Dim Cel As Range, Ws1 As Worksheet, C1 As Range
    Set Ws1 = Sheets("Sheet1")
    Set C1 = Sheets("Sheet2").Range("C1")
    C1.Offset(, 1).Resize(, 11).Copy

For Each Cel In Ws1.Range("C2", Ws1.Range("C" & Rows.Count).End(xlUp))
    If Cel = C1 Then
        With Cel.Offset(, 1)
            .PasteSpecial (xlPasteFormats)
            .PasteSpecial (xlPasteValues)
        End With
    End If
Next Cel

End Sub
 
Upvote 0
Hi Yongle, Thank you so much for this and for such a rapid responce, it works beautifully!

My VBA knowledge is very limited and so far I have gotten away with Frankenstein-ing different bits and pieces,until now. I need to learn more of the basics i obviously.

Really grateful!
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,423
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top