VBA date related copy and paste - same workbook

dnorm

Board Regular
Joined
Dec 28, 2017
Messages
125
Office Version
  1. 365
Platform
  1. Windows
Hi All

I am trying to transfer data from sheet 1 "report" in cells I11:V11 (fixed) and the date for this report is located in K1 to the corresponding date on sheet "Daily Data Input" to cells C:P (rows constantly change) where the dates are located in B:B (the entire year is listed here).
The data is to be copied as values only as the "report" sheet is formulated (I dragged the data to one side to simplify things).
I have tried several variations of other peoples code and tried in vain to adapt them to my needs.

this will be added to an existing macros to run from a button (this part I can do).
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I should add that I am currently using excel 2007 & 2010 in building this report (2010 primary)
 
Upvote 0
How about
Code:
Sub CopyToDate()

   Dim Fnd As Range
   Dim Dte As Date
   
   Dte = Sheets("Report").Range("K1").Value
   
   Set Fnd = Sheets("Daily Data Input").Columns(2).Find(Dte, , , , , , , , False)
   If Fnd Is Nothing Then
      MsgBox Dte & " Not found"
      Exit Sub
   End If
   Fnd.Offset(, 1).Resize(, 14).Value = Sheets("Report").Range("I11:V11").Value
      
End Sub
 
Upvote 0
How about
Code:
Sub CopyToDate()

   Dim Fnd As Range
   Dim Dte As Date
   
   Dte = Sheets("Report").Range("K1").Value
   
   Set Fnd = Sheets("Daily Data Input").Columns(2).Find(Dte, , , , , , , , False)
   If Fnd Is Nothing Then
      MsgBox Dte & " Not found"
      Exit Sub
   End If
   Fnd.Offset(, 1).Resize(, 14).Value = Sheets("Report").Range("I11:V11").Value
      
End Sub



Works a treat, you LEGEND! thanks!
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,655
Members
448,975
Latest member
sweeberry

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